Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
This code all works but for some weird reason it won`t delete the row??
VBA Code:
Option Explicit
Public intDeleteNonBO As Integer
Sub DeleteAnyNonBO()
Dim wb As Workbook
Dim ws As Worksheet
Dim Rng As Range, Cell As String, Col As String
Dim LRow As Long
Dim cells As Range
Dim strText As String
Dim i As Integer
intDeleteNonBO = 0
With Application
.ScreenUpdating = False
.Calculation = xlManual
.DisplayAlerts = False
.EnableEvents = False
End With
Set wb = Workbooks("2023BackOrderReport.xlsm")
Set ws = wb.Worksheets("Data")
LRow = ws.cells(Rows.Count, 1).End(xlUp).Row
Set Rng = ws.Range("I2:I" & LRow)
On Error Resume Next
For i = LRow To 2 Step -1
Col = "A"
Cell = ws.cells(i, 9).Value
If IsDate(ws.cells(i, Col).Value) And ws.cells(i, Col).Value = Date Then
If Cell Like "No Space" Then
cells(i, "A").EntireRow.Delete
ElseIf Cell Like "*Fit on Lorry" Then
cells(i, "A").EntireRow.Delete
ElseIf Cell Like "*FIT ON TRUCK" Then
cells(i, "A").EntireRow.Delete
ElseIf Cell Like "Failed Delivery" Then
cells(i, "A").EntireRow.Delete
ElseIf Cell Like "Bag Not]" Then
cells(i, "A").EntireRow.Delete
ElseIf Cell Like "Loading Picking Error" Then
cells(i, "A").EntireRow.Delete
ElseIf Cell Like "Failed Delivery" Then
cells(i, "A").EntireRow.Delete
ElseIf Cell Like "No Room on truck" Then
cells(i, "A").EntireRow.Delete
End If
End If
Next i
intDeleteNonBO = 1
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.DisplayAlerts = True
.EnableEvents = True
End With
End Sub