nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
I am running this code to delete any row that shows Yes in column C, False in column M, Or the number 1 in column AH, when i run this, only the Yes and False are being found and deleted. The 1's remain. I am however, not getting any errors, it just doesnt seem to be finding them.
VBA Code:
Dim nc As Long, i As Long, k As Long, lr As Long
Set ws = Sheets("Data")
With ws
nc = .Cells.Find(What:="*", LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
lr = .Columns("C:AH").Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
a = Application.Index(.Cells, Evaluate("row(2:" & lr & ")"), Array(3, 14, 34))
ReDim b(1 To UBound(a), 1 To 1)
For i = 1 To UBound(a)
If UCase(a(i, 1)) = "YES" Or UCase(a(i, 2)) = "FALSE" Or IsNumeric(a(i, 3)) And a(i, 3) = 1 Then
b(i, 1) = 1
k = k + 1
End If
Next i
If k > 0 Then
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
With .Range("A2").Resize(UBound(a), nc)
.Columns(nc).Value = b
.Sort Key1:=.Columns(nc), Order1:=xlAscending, Header:=xlNo
.Resize(k).EntireRow.Delete
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End If
End With