Hanging up on this line of code

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
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Welcome to the board...

If Cells(x, 2).Value = "0" Then -
Try removing the quotes from "0"


If Cells(x, 2).Value = "#N/A" Then -

Try
If IsError(Cells(x, 2)) Then


Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,445
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top