Link to home
Start Free TrialLog in
Avatar of Brian Mulder
Brian MulderFlag for Netherlands

asked on

Select case and OR statement

Hi everyone,

while stepping through code in excel i saw this

-somevalue has the value of 36.8
-in the debugger
-?Range("J" & iRow - 4) gave 0
-?Range("L" & iRow - 4) gave 36.8

so you would expect this statement to be true and teh code go into dosomething

select case somevalue
  case is = Range("J" & iRow - 4) Or Range("L" & iRow - 4)
    dosomething
  '......more comes here
end select

-the following worked as expected

select case somevalue
  case is = Range("J" & iRow - 4)
    dosomething
  case is = Range("L" & iRow - 4)
  '......more comes here
end select

-in the debugger the statement Range("J" & iRow - 4) Or Range("L" & iRow - 4) gave 37!

am i missing something here, it's not a real problem only a question maybe i'm doing something wrong in using the OR statement in the case select

:O)Bruintje
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

ASKER

replaced the line with

Case Is = Range("J" & iRow - 4): Case Is = Range("L" & iRow - 4)

which worked ok but i still want to know about the case select and the OR
ASKER CERTIFIED SOLUTION
Avatar of Bahnass
Bahnass
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think that the .Value tries to read an integer value.
Try reading it as a string ?
that did it!

thanks a lot learned something new because in VB i did the same thing Case Is = but Case X,Y seems logical

:O)Bruintje
thanks 4 points & Grade
LOL - Overread that one..... ;-)
Great catch Bahnass!

D'Mzzl!
RoverM