Hi there,
I have very limited experience with macros and even less with VBA.
I am looking to sort my data based on the column, and thought If i simply recorded my steps using the record macro function in excel that this would be possible.
The problem I am encountering is that the code created is specific to the workbook "200120 Jeff V Bolton", however I would like to be able to use this macro in different worksheets. Furthermore, if this were to work on another sheet I see that the range is to 206 rows, however some sheets may have more rows, some may have less.
Any help would be much appreciated.
I have copied and pasted the code below:
Sub Macro999()
'
' Macro999 Macro
'
'
Range("A1").Select
ActiveWorkbook.Worksheets("200120 Jeffer V Bolton").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("200120 Jefff V Bolton").Sort.SortFields. _
Add2 Key:=Range("A1:M1"), SortOn:=xlSortOnValues, Order:=xlAscending, _
CustomOrder:= _
"1st serve,2nd serve,Point won by,Serve outcome,Serve+1 Hand,Serve+1 outcome,Serve+1 Situation,Server,Side" _
, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("200120 Jeff V Bolton").Sort
.SetRange Range("A1:M206")
.Header = xlYes
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
Columns("J:M").Select
Selection.Delete Shift:=xlToLeft
End Sub
I have very limited experience with macros and even less with VBA.
I am looking to sort my data based on the column, and thought If i simply recorded my steps using the record macro function in excel that this would be possible.
The problem I am encountering is that the code created is specific to the workbook "200120 Jeff V Bolton", however I would like to be able to use this macro in different worksheets. Furthermore, if this were to work on another sheet I see that the range is to 206 rows, however some sheets may have more rows, some may have less.
Any help would be much appreciated.
I have copied and pasted the code below:
Sub Macro999()
'
' Macro999 Macro
'
'
Range("A1").Select
ActiveWorkbook.Worksheets("200120 Jeffer V Bolton").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets("200120 Jefff V Bolton").Sort.SortFields. _
Add2 Key:=Range("A1:M1"), SortOn:=xlSortOnValues, Order:=xlAscending, _
CustomOrder:= _
"1st serve,2nd serve,Point won by,Serve outcome,Serve+1 Hand,Serve+1 outcome,Serve+1 Situation,Server,Side" _
, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("200120 Jeff V Bolton").Sort
.SetRange Range("A1:M206")
.Header = xlYes
.MatchCase = False
.Orientation = xlLeftToRight
.SortMethod = xlPinYin
.Apply
End With
Columns("J:M").Select
Selection.Delete Shift:=xlToLeft
End Sub