Delete Cells with Errors @mbgeotech
Delete Cells with Errors  @mbgeotech
Uploaded November 2024 | Updated November 2026, 1 day ago
Delete Cells with Errors.
This is the code:
Sub DeleteAllNACells()
Dim ws As Worksheet
Dim lastRow As Long
Dim col As Range
Dim cell As Range

' Set the worksheet you want to work on
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet name

' Loop through columns A, B, and C
For Each col In ws.Range("A:D").Columns
' Find the last row in each column
lastRow = ws.Cells(ws.Rows.Count, col.Column).End(xlUp).Row

' Loop through each cell in the column from bottom to top
' Going from bottom to top prevents skipping rows after deletion
For i = lastRow To 1 Step -1
Set cell = col.Cells(i, 1)

' Check if the cell contains an error and if that error is #N/A
If IsError(cell.Value) Then
If cell.Value = CVErr(xlErrNA) Then
' Delete the cell and shift up
cell.Delete Shift:=xlUp
End If
End If
Next i
Next col

MsgBox "All #N/A cells have been deleted in columns A to D", vbInformation
End Sub
Delete Cells with ErrorsLiquefaction Potential using CPT dataPond Grading, with cuts calculations | CIVIL 3DSpectral Acceleration from SeismoSignalLiquefaction Analysis using CPT Data | Settle 3D RocscienceEstimate D5-75 and D5-95 using SeismoSignalSlice info in Slide2Create Charts and Figures using VBA | EXCEL VBAWSliq | Part 1: Liquefaction susceptibilityCreate Surface from DWG file | Muk3DSave Excel Sheets as PDF (allow user to choose the PDF files location) | EXCEL VBAModeling of the Feijao Dam Failure
MB GeoTech |

Delete Cells with Errors

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER