Delete Only The Rows with Numeric Value MACRO

Closed
Report
-
Posts
1864
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
-
Hello,

I am struggling with trying to figure out a macro to look through a selection of cells that have either numeric or text values, and I need to sift through the entire selection to identify the ones with a number, and if that's the case, I would need to delete the entire row. Basically in a range of

XXXXXX
111111
YYYYYYY
222222
222222
222233
TRES
TEXT

I need to look in the entire column and identify the cells with numbers and delete then, while leaving the rows with text value.

Any help with this will great.

2 replies

Posts
1864
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
803
the data is range A1 down
A1 is column heading
before running the macro copy the data safely in another sheet and save the file


data
XXXXXX
111111
YYYYYYY
222222
222222
222233
TRES
TEXT

they try this macro

Sub test()
Dim j As Integer, k As Integer, r As Range
j = Cells(Rows.Count, "A").End(xlUp).Row
For k = j To 2 Step -1
Set r = Cells(k, 1)
If IsNumeric(r) Then r.EntireRow.Delete
Next k
Thanks so much - I see that your macro is working but I can't change it to look at the date which for me is in column "P"; I tried changing it to j = Cells(Rows.Count, "P").End(xlUp).Row
But this way it doesn't work.
Posts
1864
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
803
you have correctly changed the line. one more line has to be changed

Set r = Cells(k, "P")

after changing now you try.