Deleting contents from cell if text not a number

vron1994

New Member
Joined
Jul 17, 2018
Messages
2
Hi,

I am wanting some code which will loop through a column of text as such:

[TABLE="width: 81"]
<tbody>[TR]
[TD="align: right"]40[/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD]Lynton[/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]22[/TD]
[/TR]
[TR]
[TD]Field[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]19B
[/TD]
[/TR]
</tbody>[/TABLE]
deleting the cells which do not contain just numbers!

Any help would be appreciated!

Thanks
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi & welcome to MrExcel.
Do you want to delete the cells, or the entire row?
 
Upvote 0
If you want to delete the entire row & your numbers are real numbers try
Code:
Sub c()
Range("A:A").SpecialCells(xlConstants, xlTextValues).EntireRow.Delete
End Sub
Also, if you have blank cells this code will leave them
 
Upvote 0
If you want to delete the entire row & your numbers are real numbers try
Code:
Sub c()
Range("A:A").SpecialCells(xlConstants, xlTextValues).EntireRow.Delete
End Sub
Also, if you have blank cells this code will leave them

Hi, thanks for replying!

I am just looking to clear the contents of the cell, not actually delete anything

Also I am not sure what you mean by real numbers!

Thanks
 
Upvote 0
In that case try this on a copy of your data
Code:
Sub c()
Range("A:A").SpecialCells(xlConstants, xlTextValues).ClearContents
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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