Finding cells with a number and replacing with an "X"

srhilvers

New Member
Joined
Jan 8, 2010
Messages
2
Hello...
I am trying to create a routine which finds all cells with a numerical value (no text or special characters) and replace those cells with an "X". I believe all the cells are formatted as "General".
Any pointers on how to do this?
Thank you,
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Welcome to the board!

Select the range (or entire worksheet) and press F5 to open the GoTo dialog. Click the Special button and select Constants, deselecting Text, Logicals, Errors. Then type in X and press Ctrl +Enter
 
Upvote 0
Try

Code:
Sub NosToX()
Dim c As Range
For Each c In ActiveSheet.UsedRange
    With c
        If IsNumeric(.Value) Then .Value = "X"
    End With
Next c
End Sub
 
Upvote 0
Welcome to the board!

A simple way to do it is to select all the cells you want to affect:
Goto Special (press control+G, alt+S)
Choose Constants
Check only the box for Numbers (press x,g,e to uncheck the other three)
Choose OK (press enter)
...you are now selecting all of the numbers - including dates
Press X
Press control+enter to apply the X to all of the selected cells.

In this sheet, only the second cell would not be changed to an X; the date is considered a number by Excel:

Excel Workbook
A
11
2text
315
41/8/2010
Sheet1
Excel 2003



Here is a macro to do the same thing (select the cells, then run the macro if you don't want to do control+g,alt+s,o,x,g,e,enter,X,control+enter):

Code:
Option Explicit
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/8/2010
'
'
    Selection.SpecialCells(xlCellTypeConstants, 1).Select
    Selection.FormulaR1C1 = "X"
End Sub

Hope that helps!

Tai

edit: I wrote this myself, I swear I didn't copy post #2 and #3 :-p
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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