thundardog
New Member
- Joined
- May 18, 2011
- Messages
- 19
Below is a short macro for deleting row with a specific value (0 or #N/A). These values are copied into the worksheet as "values and number format". I have tested the macro on a different work sheet and it works fine, but will not work on the work sheet I need it to. It hangs up on either of the underlined lines of code. I believe it is a formatting issue on the work sheet. Any thought or advice would be appreciated.
Sub DeleteRows()
'
' Delete Row In Dispatch Form Before Print
' Macro designed to delete a row with no driver to keep from printing
' Delete void entries in Dispatch Form spreadsheet
Sheets("Dispatch Form").Select
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
For x = FinalRow To 100 Step -1
If Cells(x, 2).Value = "0" Then
Cells(x, 1).EntireRow.Delete
End If
If Cells(x, 2).Value = "#N/A" Then
Cells(x, 1).EntireRow.Delete
End If
Next x
End Sub
Sub DeleteRows()
'
' Delete Row In Dispatch Form Before Print
' Macro designed to delete a row with no driver to keep from printing
' Delete void entries in Dispatch Form spreadsheet
Sheets("Dispatch Form").Select
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
For x = FinalRow To 100 Step -1
If Cells(x, 2).Value = "0" Then
Cells(x, 1).EntireRow.Delete
End If
If Cells(x, 2).Value = "#N/A" Then
Cells(x, 1).EntireRow.Delete
End If
Next x
End Sub