ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   conditional cell.value statement (https://www.excelbanter.com/excel-programming/360627-conditional-cell-value-statement.html)

M John

conditional cell.value statement
 
I'm running out of ideas for the following situation:

If Cell.Value 0 and Cell.Value <=0.2 then
(code)

Else If Cell.Value 0.2 and Cell.Value <=.4
(other code)

Else If Cell.Value 0.4 and Cell.Value <=.6
(other code)

Else If Cell.Value 0.6 and Cell.Value <=.8
(other code)

Else Cell.Value 0.8 and Cell.Value <=1
(other code)

End If

Is there an easier way to do this? Am I missing something obvious? Right
now, I can't figure out how to make this scheme work.

Any pointers you can give me will be gratefully received.
Thanks,
MJohn

Jim Thomlinson

conditional cell.value statement
 
What you have is not to bad, but if you wnat to you could ucse a select case
statement instead. Something like

Select Cell.Value
Case < 0
'Some code (or not)
Case <= 0.2
'More Code
Case <= 0.4
'Yet more code still
Case Else
'Did not find it code
End Select
--
HTH...

Jim Thomlinson


"M John" wrote:

I'm running out of ideas for the following situation:

If Cell.Value 0 and Cell.Value <=0.2 then
(code)

Else If Cell.Value 0.2 and Cell.Value <=.4
(other code)

Else If Cell.Value 0.4 and Cell.Value <=.6
(other code)

Else If Cell.Value 0.6 and Cell.Value <=.8
(other code)

Else Cell.Value 0.8 and Cell.Value <=1
(other code)

End If

Is there an easier way to do this? Am I missing something obvious? Right
now, I can't figure out how to make this scheme work.

Any pointers you can give me will be gratefully received.
Thanks,
MJohn


M John

conditional cell.value statement
 
Excellent work. Many thanks and much admiration.

MJohn

"Jim Thomlinson" wrote:

What you have is not to bad, but if you wnat to you could ucse a select case
statement instead. Something like

Select Cell.Value
Case < 0
'Some code (or not)
Case <= 0.2
'More Code
Case <= 0.4
'Yet more code still
Case Else
'Did not find it code
End Select
--
HTH...

Jim Thomlinson


"M John" wrote:

I'm running out of ideas for the following situation:

If Cell.Value 0 and Cell.Value <=0.2 then
(code)

Else If Cell.Value 0.2 and Cell.Value <=.4
(other code)

Else If Cell.Value 0.4 and Cell.Value <=.6
(other code)

Else If Cell.Value 0.6 and Cell.Value <=.8
(other code)

Else Cell.Value 0.8 and Cell.Value <=1
(other code)

End If

Is there an easier way to do this? Am I missing something obvious? Right
now, I can't figure out how to make this scheme work.

Any pointers you can give me will be gratefully received.
Thanks,
MJohn



All times are GMT +1. The time now is 01:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com