Hi everyone
i have created a macro that sorts a range of cells F8:F21 accending, this works really well
the code i use for this is
Range("E7:H21").Select
ActiveWorkbook.Worksheets("BNS").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("BNS").Sort.SortFields.Add Key _
:=Range("F8:F21"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("BNS").Sort
.SetRange Range("E7:H21")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
how can i change this code so that the active worksheet name is captured?
this code runs on the worksheet "BNS"
all the worksheets are dynamically created from a list and they can be different each time the spreadsheet runs,
is it possible to change this ActiveWorkbook.Worksheets("BNS").Sort.SortFields.Clear
to capture the active worksheet name?
many thanks
steve
i have created a macro that sorts a range of cells F8:F21 accending, this works really well
the code i use for this is
Range("E7:H21").Select
ActiveWorkbook.Worksheets("BNS").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("BNS").Sort.SortFields.Add Key _
:=Range("F8:F21"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("BNS").Sort
.SetRange Range("E7:H21")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
how can i change this code so that the active worksheet name is captured?
this code runs on the worksheet "BNS"
all the worksheets are dynamically created from a list and they can be different each time the spreadsheet runs,
is it possible to change this ActiveWorkbook.Worksheets("BNS").Sort.SortFields.Clear
to capture the active worksheet name?
many thanks
steve