muzikman69
New Member
- Joined
- Jun 19, 2007
- Messages
- 30
Good day,
A portion of one of my macros is to sort the active worksheet, after a series of other steps from bring in some Oracle information. This macro may need to be applied to multiple sheets within a workbook, which has made me hesitant to rename the sheet.
The portion of the code is shown below, I am trying to get "Sheet1" out of the formula and essentially make it ActiveWorksheet (ie. generic)... but I seem to be missing something. Any ideas on how to do this?
Cheers,
Graeme,
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=ActiveCell. _
Offset(0, 6).Range("A1:A99999"), SortOn:=xlSortOnValues, Order:=xlAscending _
, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange ActiveCell.Offset(-1, 0).Range("A1:L100000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
A portion of one of my macros is to sort the active worksheet, after a series of other steps from bring in some Oracle information. This macro may need to be applied to multiple sheets within a workbook, which has made me hesitant to rename the sheet.
The portion of the code is shown below, I am trying to get "Sheet1" out of the formula and essentially make it ActiveWorksheet (ie. generic)... but I seem to be missing something. Any ideas on how to do this?
Cheers,
Graeme,
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=ActiveCell. _
Offset(0, 6).Range("A1:A99999"), SortOn:=xlSortOnValues, Order:=xlAscending _
, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange ActiveCell.Offset(-1, 0).Range("A1:L100000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With