I am completely new to VBA and what I know I've learned from Google so please be patient and kind...I'm learning.
I have several workbooks (one per campus) with multiple worksheets (one per teacher) with data that needs to be sorted by column F (LEP) and then column D (Student Name). Rows in which column F is blank or equal to "LEP" needs to be deleted.
I have part of this figured out using:
Sub LoopAllSheetsInOpenWorkbooks()
Dim wb As Workbook
Dim sht As Worksheet
For Each wb In Application.Workbooks
If wb.Name <> "PERSONAL.xlsb" Then
For Each sht In wb.Worksheets
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range("F2:F20000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range("D2:D20000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range("A2:F20000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Next sht
End If
Next wb
End Sub
______________________________________________________
It sorts for one worksheet and looks like it is for other worksheets in a workbook (page blinks really fast) but other worksheets are not sorted.
Also, I have no clue about deleting rows based on certain criteria. Any help would be greatly appreciated.
Bookmarks