View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Paul Paul is offline
external usenet poster
 
Posts: 1
Default Macro Error When It Can't Find Value

On Mar 30, 8:43 am, JE McGimpsey wrote:
Take a look he

http://mcgimpsey.com/excel/postfixnegatives.html

In article ,



tedd13 wrote:
I am using the following code to move the negative sign from the back of a
number to the front of the number:
For Each cell In Selection.SpecialCells(xlConstants, xlTextValues)
s = Trim(cell)
If IsNumeric(s) Then
cell.Value = CDbl(s)
End If
Next
This code works when there is a negative in the column. However, it does
not work when it can't find a negative. It gives me a "Run-time error
'1004': No cells were found".
Does anyone know how to code this so that the macro keeps going and dosn't
error out?
Thanks- Hide quoted text -


- Show quoted text -


All you have to do to get your code to work is change
SpecialCells(xlConstants, xlTextValues) to SpecialCells(xlConstants)