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 fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

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
 

Forum statistics

Threads
1,176,348
Messages
5,902,635
Members
434,983
Latest member
JenniferNash

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