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

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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