Dim rngFound As Range, rngToDelete As Range, rngFruit As Range
Dim strFirstAddress As String
Dim varList As Variant
Dim lngCounter As Long
Sub Mod_15()
Sheets("Totals").Select
'Sub Del_Rows_with_Text_in_ColX_BEST()
Const strFRUITHEADER As String = "Description"
' Dim rngFound As Range, rngToDelete As Range, rngFruit As Range
' Dim strFirstAddress As String
' Dim varList As Variant
' Dim lngCounter As Long
Application.ScreenUpdating = False
Set rngFruit = ActiveSheet.Rows(1).Find( _
what:=strFRUITHEADER, _
Lookat:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False _
)
If Not rngFruit Is Nothing Then
varList = VBA.Array("", "Produce totals", "Product totals")
For lngCounter = LBound(varList) To UBound(varList)
With rngFruit.EntireColumn
Set rngFound = .Find( _
what:=varList(lngCounter), _
Lookat:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False _
)
If Not rngFound Is Nothing Then
If rngToDelete Is Nothing Then
Set rngToDelete = rngFound
Else
Set rngToDelete = Application.Union(rngToDelete, rngFound)
End If
strFirstAddress = rngFound.Address
Set rngFound = .FindNext(After:=rngFound)
Do Until rngFound.Address = strFirstAddress
Set rngToDelete = Application.Union(rngToDelete, rngFound)
Set rngFound = .FindNext(After:=rngFound)
Loop
End If
End With
Next lngCounter
If Not rngToDelete Is Nothing Then rngToDelete.EntireRow.Delete
End If
Application.ScreenUpdating = True
'End Sub
Sheets("Picked").Select
'Sub Del_Rows_with_Text_in_ColX_BEST()
Const strFRUITHEADER As String = "Description"
' Dim rngFound As Range, rngToDelete As Range, rngFruit As Range
' Dim strFirstAddress As String
' Dim varList As Variant
' Dim lngCounter As Long
Application.ScreenUpdating = False
Set rngFruit = ActiveSheet.Rows(1).Find( _
what:=strFRUITHEADER, _
Lookat:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False _
)
If Not rngFruit Is Nothing Then
varList = VBA.Array("", "Opened Totals")
For lngCounter = LBound(varList) To UBound(varList)
With rngFruit.EntireColumn
Set rngFound = .Find( _
what:=varList(lngCounter), _
Lookat:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False _
)
If Not rngFound Is Nothing Then
If rngToDelete Is Nothing Then
Set rngToDelete = rngFound
Else
Set rngToDelete = Application.Union(rngToDelete, rngFound)
End If
strFirstAddress = rngFound.Address
Set rngFound = .FindNext(After:=rngFound)
Do Until rngFound.Address = strFirstAddress
Set rngToDelete = Application.Union(rngToDelete, rngFound)
Set rngFound = .FindNext(After:=rngFound)
Loop
End If
End With
Next lngCounter
If Not rngToDelete Is Nothing Then rngToDelete.EntireRow.Delete
End If
Application.ScreenUpdating = True
'End Sub
Sheets("Shipped").Select
'Sub Del_Rows_with_Text_in_ColX_BEST()
Const strFRUITHEADER As String = "Description"
' Dim rngFound As Range, rngToDelete As Range, rngFruit As Range
' Dim strFirstAddress As String
' Dim varList As Variant
' Dim lngCounter As Long
Application.ScreenUpdating = False
Set rngFruit = ActiveSheet.Rows(1).Find( _
what:=strFRUITHEADER, _
Lookat:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False _
)
If Not rngFruit Is Nothing Then
varList = VBA.Array("", "Region totals", "Produce totals")
For lngCounter = LBound(varList) To UBound(varList)
With rngFruit.EntireColumn
Set rngFound = .Find( _
what:=varList(lngCounter), _
Lookat:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False _
)
If Not rngFound Is Nothing Then
If rngToDelete Is Nothing Then
Set rngToDelete = rngFound
Else
Set rngToDelete = Application.Union(rngToDelete, rngFound)
End If
strFirstAddress = rngFound.Address
Set rngFound = .FindNext(After:=rngFound)
Do Until rngFound.Address = strFirstAddress
Set rngToDelete = Application.Union(rngToDelete, rngFound)
Set rngFound = .FindNext(After:=rngFound)
Loop
End If
End With
Next lngCounter
If Not rngToDelete Is Nothing Then rngToDelete.EntireRow.Delete
End If
Application.ScreenUpdating = True
'End Sub
Sheets("Received").Select
'Sub Del_Rows_with_Text_in_ColX_BEST()
Const strFRUITHEADER As String = "Description"
' Dim rngFound As Range, rngToDelete As Range, rngFruit As Range
' Dim strFirstAddress As String
' Dim varList As Variant
' Dim lngCounter As Long
Application.ScreenUpdating = False
Set rngFruit = ActiveSheet.Rows(1).Find( _
what:=strFRUITHEADER, _
Lookat:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False _
)
If Not rngFruit Is Nothing Then
varList = VBA.Array("", "Region Totals", "Produce totals")
For lngCounter = LBound(varList) To UBound(varList)
With rngFruit.EntireColumn
Set rngFound = .Find( _
what:=varList(lngCounter), _
Lookat:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False _
)
If Not rngFound Is Nothing Then
If rngToDelete Is Nothing Then
Set rngToDelete = rngFound
Else
Set rngToDelete = Application.Union(rngToDelete, rngFound)
End If
strFirstAddress = rngFound.Address
Set rngFound = .FindNext(After:=rngFound)
Do Until rngFound.Address = strFirstAddress
Set rngToDelete = Application.Union(rngToDelete, rngFound)
Set rngFound = .FindNext(After:=rngFound)
Loop
End If
End With
Next lngCounter
If Not rngToDelete Is Nothing Then rngToDelete.EntireRow.Delete
End If
Application.ScreenUpdating = True
End Sub