# delete row macro question....

#### mdcampbell1

##### New Member
vb code question. i am trying to understand how to get a macro using vb to:
if i have a column of numbers, go through the whole column and identify any number that is less than say 10,000 and then select the entire row that number is on and delete the entire row. continue the process through the entire column. also, some cells in the column will be blank (delete), words (delete), and symbols such as # (delete).

i'm a relative novice here so any help would be appreciated.

Thanks,
MDC

### Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Something like

Code:
``````Sub dl()
Dim lastrow As Long, MyCol As Integer, i As Integer, x As Variant
Application.ScreenUpdating = False
Application.Calculation = xlManual
MyCol = 1 ' change to suit
lastrow = Cells(Rows.Count, MyCol).End(xlUp).Row
For i = lastrow To 1 Step -1
x = Cells(i, MyCol).Value
If x < 10000 Or Not IsNumeric(x) Or x = "" Then Cells(i, MyCol).EntireRow.Delete
Next i
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub``````

Edit: changed lastrow= to refer to MyCol.

Does something like this do the trick... I am assuming that your first line of data is headers and I am checking column A in this code

Code:
``````Sub Test()
Dim lastrow As Long, firstrow As Long, r As Long, Ce As Range

Application.ScreenUpdating = False
With ActiveSheet.UsedRange
firstrow = .Cells(1).Row + 1
lastrow = .Cells(.Cells.Count).Row
End With

For r = lastrow To firstrow Step -1
Set Ce = Cells(r, 1)
If (Not IsNumeric(Ce.Value)) Or (Ce.Value < 10000) Then Ce.EntireRow.Delete
Next r
Application.ScreenUpdating = True

End Sub``````

thanks for the help!

Replies
15
Views
460
Replies
5
Views
172
Replies
3
Views
202
Replies
5
Views
222
Replies
22
Views
596

1,221,525
Messages
6,160,329
Members
451,637
Latest member
hvp2262

### 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.

### Which adblocker are you using?

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

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