View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ronald Dodge Ronald Dodge is offline
external usenet poster
 
Posts: 111
Default Error indicators in cells

Assuming that Range A1 has the numeric value of "1" and you put in a text
number in Range A2, then run the following snippet:

If Range("A2").Errors.Item(xlNumberAsText).Value = True Then
intResponse = MsgBox("Cell A2 has a number as text.",68,"Number as
Text")
If intResponse = 6 Then
Range("A1").Copy

Range("A2").PasteSpecial(xlPasteValues,xlPasteSpec ialOperationMultiply,False
,False)
End If
Else
MsgBox "Cell A1 is a number."
End If

Or if you prefer to just apply the copy and paste to a whole range, you can
do that too without necessarily having to check to see of the range is
numeric or text format of numbers, which is the method I had to use back in
the XL97 days. Main reason why I had to use this method back then, I tended
to use string functions for bringing down some of the information to reduce
the amount of data entry, but at the same time, it converted the numbers to
values, which didn't sort too well, so I had to use the above method to be
able to sort properly.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Trevor" wrote in message
...
In the KB article Q291047 it is stated:

Method 1: Use the Error Button
If the cells in which numbers are displayed as text
contain an error
indicator in the upper-left corner, follow these steps:
Click the cell that contains the error indicator.
Click the error button next to the cell, and then click
Convert to
Number on the shortcut menu

How can I do the same thing through VBA?

Thanks
Trevor