I have the macro below recorded for sheet 3, I would like it to run on sheet three through to sheet 369, could anyone enlighten me.
Thanks in advance.
Sub sort()
'
' sort Macro
'
' Keyboard Shortcut: Ctrl+a
'
ActiveWorkbook.Worksheets("Sheet3").sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet3").sort.SortFields.Add Key:=Range("G1:G92") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet3").sort
.SetRange Range("A1:I92")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

Try this:

For i = 1 To ActiveWorkbook.Sheets.Count
'
ActiveWorkbook.Sheets(i).Activate
Range("A1:A192").sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("G1:G92").sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.