LutonBarry
11-21-2015, 01:58 AM
I 'm trying to code a dynamic Sort range, as you can see below I'm trying to create a Dim and insert the Dim into the code but how?
Macro1 Macro
'
'
Dim myCells As Range
Range("A1").CurrentRegion.Select
Set myCells = Range("A1").CurrentRegion
ActiveWorkbook.Worksheets("Finished Sheet").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Finished Sheet").Sort.SortFields.Add Key:=Range( _
"B2:B15"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Finished Sheet").Sort
.SetRange Range("A1:D15")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Macro1 Macro
'
'
Dim myCells As Range
Range("A1").CurrentRegion.Select
Set myCells = Range("A1").CurrentRegion
ActiveWorkbook.Worksheets("Finished Sheet").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Finished Sheet").Sort.SortFields.Add Key:=Range( _
"B2:B15"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Finished Sheet").Sort
.SetRange Range("A1:D15")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub