problem with code

  • Thread starter Thread starter gareth
  • Start date Start date
G

gareth

I need to use the following code on a column containing
formula. It works if there are just values in the range
but my range has formula in it.

Sub tester()
For Each cell In Range("B2:B20")
If cell.Value > 0 Then
cell.Offset(0, -1).Value = "Yes"
End If
Next
End Sub

Thanks in advance.

Gareth
 
The code you show should work whether there are formula or not. The only
problem I can see if is the cell value is text, then you might have a
problem with the if statement.

Sub tester()
For Each cell In Range("B2:B20")
if not isempty(cell.Value) then
if isnumeric(cell.Value) then
If cell.Value > 0 Then
cell.Offset(0, -1).Value = "Yes"
End if
end if
End If
Next
End Sub
 
Back
Top