I have built series of VBA macros to work through some steps for a user. I have built a button to for a user to click to remove any row that contains #N/A. One of my earlier steps makes this just a plain text value.
When executing the action it appears to run through but just moves my view to the worksheet i am trying to clean up and doesn't actually delete any rows.
I have tried switching parts of the code so instead of = to like
Sub DeleteNAsOnFrank_Click()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With Sheets("Frank Import Full List")
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Lrow = Lastrow To Firstrow Step -1
With .Cells(Lrow, "A")
If Not IsError(.Value) Then
If .Value = "#N/A" Then .EntireRow.Delete
End If
End With
Next Lrow
End With
ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
I expect it to delete any row that contains the text If .Value = "#N/A" Then .EntireRow.Delete
on the Sheets("Frank Import Full List")