Nikit Strygin
New Member
- Joined
- Aug 19, 2021
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi!
I'm trying to make a VBA which would allow me to delete entire rows on the specific worksheets if #N/A were found simultaneously in columns A, B & C. For now I'm stucked with error "1004 object defined error". I would be very thankful for your help! Thank you in advance
I'm trying to make a VBA which would allow me to delete entire rows on the specific worksheets if #N/A were found simultaneously in columns A, B & C. For now I'm stucked with error "1004 object defined error". I would be very thankful for your help! Thank you in advance
VBA Code:
Sub CleanNA()
Dim ws As Variant
Dim x As Long
Dim columnsrange As Variant
ws = Array("Sheet 1", "Sheet 2", "Sheet 3")
Set columnsrange = Range("A:C")
For x = 0 To UBound(ws)
If ActiveWorkbook.Sheets(ws(x)).Range(columnsrange).Cells.Value = CVErr(xlErrNA) Then
ActiveWorkbook.Sheets(ws(x)).Cells.SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Clear
ActiveWorkbook.Sheets(ws(x)).Cells.SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Clear
End If
Next
Application.ScreenUpdating = True
MsgBox ("#N/A were successfully cleaned")
End Sub