Trying to sort multiple sheets, used an array and unfortunately getting "Cannot set array" error. Not sure what is being done wrong here. Here is my code:
Sub Macro1()
Dim ws() As Variant
Dim wb As Workbook
Set wb = ThisWorkbook
Set ws() = wb.Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
'
' Macro1 Macro
'
'
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ws.Sort
.SetRange Range("A1:B6")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
For Each ws in Worksheets