mn_voyageur
New Member
- Joined
- Aug 7, 2018
- Messages
- 5
Just starting to learn the details of VBA.
Recorded the following for sorting based upon Column A.
Does "8_7_18 CSV Report" prevent the sort from executing, if the worksheet is not "8_7_18 CSV Report"? If so, how do I make this more generic? (Run on the active worksheet.)
Thanks,
MarkN
Sub Macro6()
'
' Macro6 Macro
'
'
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Cut
Columns("D:D").Select
ActiveSheet.Paste
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
ActiveWorkbook.Worksheets("8_7_18 CSV Report").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("8_7_18 CSV Report").Sort.SortFields.Add Key:=Range _
("A1:A236"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("8_7_18 CSV Report").Sort
.SetRange Range("A1:I236")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Recorded the following for sorting based upon Column A.
Does "8_7_18 CSV Report" prevent the sort from executing, if the worksheet is not "8_7_18 CSV Report"? If so, how do I make this more generic? (Run on the active worksheet.)
Thanks,
MarkN
Sub Macro6()
'
' Macro6 Macro
'
'
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Cut
Columns("D:D").Select
ActiveSheet.Paste
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Cells.Select
ActiveWorkbook.Worksheets("8_7_18 CSV Report").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("8_7_18 CSV Report").Sort.SortFields.Add Key:=Range _
("A1:A236"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("8_7_18 CSV Report").Sort
.SetRange Range("A1:I236")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub