Hello,
this is a very basic question, I am sorry to ask. I have created a macro in excel that I want to run in the current worksheet that is selected. How do I do this? For example, I have a sortZip Macro that I want to run on several worksheets when I hit the RUN button but it only works on the worksheet that I originally created the macro on.
I would really appreciate your advice on this!!! - Please :D
Code is:
Sub SortZip()
'
' SortZip Macro
'
'
ActiveWorkbook.Worksheets("GilbertApril09").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("GilbertApril09").Sort.SortFields.Add Key:=Range( _
"H2:H390"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("GilbertApril09").Sort.SortFields.Add Key:=Range( _
"L2:L390"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("GilbertApril09").Sort
.SetRange Range("A1:L390")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
System Configuration: Windows Vista Internet Explorer 7.0
I was fearing I would have to rewrite the whole thing in a new workbook or create one workbook for each project but now I can add sheets along with the projects