I have a macro that I'm using to alphabetize an attendance list and then delete the 'Blank' rows (the cells actually return "" so, when sorted in descending order, they appear above the sorted list of names)
Below is the code, that seems to work perfectly - but it currently only runs in the sheet labelled "1", and I would like it to run in 8 sheets which are all labelled in numerical order, i.e. "1", "2", "3", "4", "5", "6", "7" and "8"
Below is the code, that seems to work perfectly - but it currently only runs in the sheet labelled "1", and I would like it to run in 8 sheets which are all labelled in numerical order, i.e. "1", "2", "3", "4", "5", "6", "7" and "8"
VBA Code:
Sub SortPOSurnames()
'
' test
'
ActiveWorkbook.Worksheets("1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("1").Sort.SortFields.Add Key:=Range("D3:D42"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("1").Sort
.SetRange Range("A3:E42")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
With ActiveSheet
.AutoFilterMode = False
With Range("d1", Range("d" & Rows.Count).End(xlUp))
.AutoFilter 1, ""
On Error Resume Next
.Offset(2).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub