+ Reply to Thread
Results 1 to 8 of 8

Can you have a compound select case construction?

  1. #1
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Can you have a compound select case construction?

    I know the normal format, but can't figure out how to do a compound statement like you can with the "If statement". With the "If" statement you can use the word "and" between the conditions.

    With select case is there an equivalent or you can you only do one case at a time?

    For example...

    Select Case j
    Case (is <= opVac and is <=rMths)
    end select

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Can you have a compound select case construction?

    Is this what you mean?
    Please Login or Register  to view this content.
    If any of the 4 cases is true it will do it's thing.

    Or you can do a Select Case within a Select Case

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Can you have a compound select case construction?

    You can also use a Select Case True construction, but I don't generally see any point in using Select Case over If for a situation like that.
    Rory

  4. #4
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Can you have a compound select case construction?

    Quote Originally Posted by jolivanes View Post
    Is this what you mean?
    Please Login or Register  to view this content.
    If any of the 4 cases is true it will do it's thing.

    Or you can do a Select Case within a Select Case
    Yes, but would it also work for numerical comparisons?

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Can you have a compound select case construction?

    Re: "Yes, but would it also work for numerical comparisons?"
    What happened when you tried with (no need for the UCase)?
    Case 2, 4, 6 ,8

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Can you have a compound select case construction?

    Off topic but related.

    I have had problems in the past with the following construction @jolivanes used in post #2:
    Please Login or Register  to view this content.
    The UCase occassionally did not get interpreted properly. My speculation is that 'Select Case' is expecting a a value.

    I usually use the following in its stead.
    Please Login or Register  to view this content.
    Lewis

  7. #7
    Forum Contributor
    Join Date
    04-01-2010
    Location
    USA
    MS-Off Ver
    Office 2021
    Posts
    185

    Re: Can you have a compound select case construction?

    Thanks for explaining! I'm stuck on this array part now that comes before the place I'd need this, but will come back to it.

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Can you have a compound select case construction?

    Thanks Lewis.
    I just copied that code from something I had.
    Thank you for showing/correcting me.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Select Case with multiple lines in a case statement?
    By jGKpZ8a33sPrnqX8fam7 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-02-2017, 10:25 AM
  2. [SOLVED] Need the proper syntax to use Case/Select Case in vba properly.
    By rbion in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-16-2013, 02:34 PM
  3. [SOLVED] Disregard case in VBA code. (UCase, LCase, Select Case)
    By Orestees in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-07-2012, 12:12 PM
  4. Case Select compile error "Case without case select"
    By coasterman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2012, 06:50 AM
  5. Problem with Select Case construction
    By s80NL in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2009, 05:49 PM
  6. Case Select....The alternative method for long "Select Case"
    By kimyap in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2008, 01:24 AM
  7. [SOLVED] Error in code re case construction
    By PFL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-06-2005, 04:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1