VBA Code: Delete Row if NOT numeric

jbeck

New Member
Joined
Jun 7, 2010
Messages
20
I know enough about VBA code just to be dangerous. I am trying to get my macro to look through my spreadsheet line by line to determine whether to delete the entire row based on the value in column A being numeric or not. I have tried the following code, but it blows up saying I need inputs in line 3. Some of the lines in the spreadsheet are blank (no value). Could this be the problem. The spreadsheet ALWAYS has 225 lines, if that would help to just count the rows it looks at. Please advise.

1 LR = Cells(Rows.Count, 1).End(xlUp).Row
2 For i = LR To 2 Step -1
3 If Range("A" & i) = Not IsNumeric(Cell.Value) Then
4 Range("A" & i).EntireRow.Delete Shift:=xlUp
5 End If
6 Next i
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
1 LR = Cells(Rows.Count, 1).End(xlUp).Row
2 For i = LR To 2 Step -1
3 If Not IsNumeric(Range("A" & i).Value) Then
4 Range("A" & i).EntireRow.Delete
5 End If
6 Next i
 

Watch MrExcel Video

Forum statistics

Threads
1,133,278
Messages
5,657,817
Members
418,414
Latest member
ECMdusty

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
Top