Delete Only The Rows with Numeric Value MACRO

Closed
NewbieinSF - 13 Sep 2010 à 18:12
venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 - 15 Sep 2010 à 21:13
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.

Related:

2 responses

venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 811
13 Sep 2010 à 22:34
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.
venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 811
15 Sep 2010 à 21:13
you have correctly changed the line. one more line has to be changed

Set r = Cells(k, "P")

after changing now you try.