Hi All, I'm sure this is a simple one for your veterans....I'm just getting started with Excel macros. Below is a macro definition. I created this macro (Sort1) while inside a file named "FileA".
I'm trying to make it so that this macro can be used inside any Excel file that I happen to be in. I have created/stored the excel macro in my Personal folder that is viewable to all other Excel files. The problem I'm having is that the macro below gets created with a hard-coded file name ("FileA"). How do I modify this macro so that it works on the "current file" (any Excel file that I happen to be in).
Your help is greatly appreciated!
Thanks,
Chris
Sub Sort1()
'
' Sort1 Macro
'
'
Rows("2:9").Select
Range("AW2").Activate
ActiveWorkbook.Worksheets("FileA").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("FileA").Sort.SortFields.Add Key:=Range( _
"BH2:BH9"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("FileA").Sort.SortFields.Add Key:=Range( _
"AW2:AW9"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("FileA").Sort
.SetRange Range("A2:BO9")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Bookmarks