Finding text and replacing in VBA
Hi,
The following will replace any cell which has non-numeric data with
0; this will include data such as ABC123 or 12AB45 etc. which will be set to
0 not 0123 or 12045. Is this what you want?
It looks as though you need to add code which checks for numeric-only input
to avoid a repeat of this problem.
Sub ReplaceTextWithZero()
Dim rng As Range, cell
Set rng = Range("a1:Z1000") ' <==== Replace as required
For Each cell In rng
If Not IsNumeric(cell) Then
cell.Value = 0
End If
Next cell
End Sub
HTH
" wrote:
Dear All,
we have a pricing template that some turkeys decide to include text in
it when filling it out.
How can I find and replace ANY text that appears in the range? The
variance of entered text is huge, so there is no way to find and
replace specific text.
We want to replace any text with a zero ("0").
Basically, we need to go from cell to cell, find an instance of text,
then replace it with zero.
Help would be greatly appreciated...
Regards,
andym
|