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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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