Sub MyReplace()
Dim rng As Range
Dim cell As Range
Application.ScreenUpdating = False
' Set range to apply this to
Set rng = Range("A1:C5")
' Loop through all cells in range
For Each cell In rng
If IsNumeric(cell) Then cell.ClearContents
Next cell
Application.ScreenUpdating = True
End Sub
One way is to loop through the range that you want to apply this to, and check to see if the entry is numeric with the IsNumeric function, i.e.
Code:Sub MyReplace() Dim rng As Range Dim cell As Range Application.ScreenUpdating = False ' Set range to apply this to Set rng = Range("A1:C5") ' Loop through all cells in range For Each cell In rng If IsNumeric(cell) Then cell.ClearContents Next cell Application.ScreenUpdating = True End Sub
Does ALL numbers include numbers returned by formulas or just numeric constants? If formulas are included do you want to replace the formulas with blanks?Is there a way to replace numbers with blanks.
Example:
.replace what:="number", replacement:=""
I want to replace all numbers....
Thanks!
Is there a way to replace numbers with blanks.
Example:
.replace what:="number", replacement:=""
I want to replace all numbers....
Thanks!
Sub MyReplaceNums()
Dim rng As Range
Dim cell As Range
Dim nums As String
Dim rep As String
Dim i As Long
Application.ScreenUpdating = False
' Set values to replace
nums = "0123456789"
' Set range to do replacements
Set rng = Range("A1:A10")
' Loop through all cells in range
For Each cell In rng
' Loop through all numbers
For i = 1 To Len(nums)
' Get number to replace
rep = Mid(nums, i, 1)
' Do replacement
With cell
.Replace what:=rep, replacement:=""
End With
Next i
Next cell
Application.ScreenUpdating = True
End Sub