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
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
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
[vba]
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
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
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
Yeah, the final do something else is just do nothing.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Whilst not needed here, check out Select Case in VBA Help if you have multiple options.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
As you say. may not be needed here, but it is always more readable (IMO).Originally Posted by mdmackillop
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber