I am trying to use a macro across a number of worksheets in a workbook I am not very good at writing VBA so just record it but from some reason the macro just references the one sheet how do I change it so that it doesnt just look for the same sheet all the time? Also the number of rows varies in each sheet how do I get it to select however many rows there are?
Columns("B:B").Select
ActiveWorkbook.Worksheets("F1711412").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("F1711412").Sort.SortFields.Add2 Key:=Range( _
"B2:B91"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("F1711412").Sort
.SetRange Range("B1:B91")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A50")
Range("A2:A50").Select
Range("B1").Select
Columns("B:B").Select
ActiveWorkbook.Worksheets("F1711412").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("F1711412").Sort.SortFields.Add2 Key:=Range( _
"B2:B91"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("F1711412").Sort
.SetRange Range("B1:B91")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A50")
Range("A2:A50").Select
Range("B1").Select