Solved

Select case and OR statement

Posted on 2002-03-23
6
134 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:bruintje
  • 2
  • 2
  • 2
6 Comments
 
LVL 44

Author Comment

by:bruintje
ID: 6891405
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
0
 
LVL 3

Accepted Solution

by:
Bahnass earned 51 total points
ID: 6891431
I think
case Range("J" & iRow - 4) , Range("L" & iRow - 4)


in VB we say

SELECT CASE VARA
    CASE A,B
        ' means vara = a or vara=b
        dosomething
    case c

    case is > C

    Case ELSE

end select
   
0
 
LVL 12

Expert Comment

by:roverm
ID: 6891432
I think that the .Value tries to read an integer value.
Try reading it as a string ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 44

Author Comment

by:bruintje
ID: 6891439
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
0
 
LVL 3

Expert Comment

by:Bahnass
ID: 6891582
thanks 4 points & Grade
0
 
LVL 12

Expert Comment

by:roverm
ID: 6892002
LOL - Overread that one..... ;-)
Great catch Bahnass!

D'Mzzl!
RoverM
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now