View Full Version : Solved: Help with value testing
Blackie50
06-03-2010, 12:54 AM
Hi,
Struggling a bit with the logic (and code) for the following
I need to rest the contents of a cell e.g. A1 and run some code depending on its value - I have 3 different situations
1
Blackie50
06-03-2010, 12:55 AM
whoops
is the cell zero or above
is the cell below zero but not greater than -1
is the cell less than -1
thanks
Jon
Bob Phillips
06-03-2010, 01:29 AM
With Range("A1")
If .Value2 < -1 Then
'do something
ElseIf .Value2 < 0 Then
'do something else
Else
'final do something else
End If
End With
Blackie50
06-03-2010, 03:06 AM
Thanks XLD - might have confused things - I will explain more
If cell value is 0(zero) or above the do nothing
If cell value is below zero but not greater than -1 then do something
If cell value is less than -1 (e.g. -1.2) then do something else
Does your logic still apply?
thanks again
Bob Phillips
06-03-2010, 03:21 AM
Yeah, the final do something else is just do nothing.
mdmackillop
06-03-2010, 09:01 AM
Whilst not needed here, check out Select Case in VBA Help if you have multiple options.
Bob Phillips
06-03-2010, 09:57 AM
Whilst not needed here, check out Select Case in VBA Help if you have multiple options.
As you say. may not be needed here, but it is always more readable (IMO).
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.