Solved

Select case and OR statement

Posted on 2002-03-23
6
142 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month4 days, 11 hours left to enroll

636 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