Error 2015

G

Guest

Hi everybody,
I'm checking values thru a column but when it gets to #VALUE! is ignoring
the condition and setting the active cell to blue (index 8). Is there anyway
to catch this error and make the condition work?
Any help will be greatly appreciated

....part of code not working...

For i = 1 To LastRow
On Error Resume Next

If ActiveCell.Offset(0, 0).Value > "0.895" And
ActiveCell.Offset(0, 0).Value < "1.1049" And _
Left(ActiveCell.Offset(0, -3).Value, 14) = "0.080 = QC STD"
Then
ActiveCell.Offset(0, 0).Interior.ColorIndex = 8

ElseIf (ActiveCell.Offset(0, 0).Value < "0.895" Or
ActiveCell.Offset(0, 0).Value > "1.1049") And _
Left(ActiveCell.Offset(0, -3).Value, 14) = "0.080 = QC STD"
Then
ActiveCell.Offset(0, 0).Interior.ColorIndex = 44

'other conditions all working great

End If
ActiveCell.Offset(1, 0).Select
Next i
 
D

Dave Peterson

If iserror(activecell.value) then
activecell.Interior.ColorIndex = 33
else
if activecell.value > 0.895 ....


(did you really want the double quotes around your numeric values?)
 
G

Guest

:)
David: Once again, thanks so much for your help. It's catching the error!
I've took the double quotes around the numeric values but it is not making
any difference... just looks better... Thanks!
Gaba
 
D

Dave Peterson

VBA is pretty forgiving in lots of things--but not always...so I try to be
careful (so I don't have to remember what VBA coerces and what it doesn't.)
:)
David: Once again, thanks so much for your help. It's catching the error!
I've took the double quotes around the numeric values but it is not making
any difference... just looks better... Thanks!
Gaba
 
G

Guest

Thanks Dave, another good lesson learnt today :)
I took all the quotes off and from now on I'll remember.

Gaba
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top