Consulting

Results 1 to 3 of 3

Thread: Limit of Case select?

  1. #1
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location

    Limit of Case select?

    In an earlier post (VBA If Module) John kindly suggested that one method to be used was with using a multiple "case" in a Case Select argument. Is there a limit to the number of "Case" arguments and, can "Case type arguments be nested?

    For Example, if you had a number of fruit or veges as the initial case select, could you then nest a secondary case argument, as in to determine the volume of fruit being sold ( Carton, 1/2 Carton, bunch, kilo, dozen)?

    Ted
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  2. #2
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    Yes you can nest them

        Select Case Fruit
    Case "Apple"
    Select Case Package
    Case "Single"
    Case "Carton"
    Case "Kilo"
            End Select
        Case "Banana"
    Select Case Package
    Case "Single"
            Case "Bunch"
            Case "Box"
            End Select
        End Select
    But it is only worth nesting if the inner case test are different from each other.
    Cheers
    Andy

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    Thank you Andy.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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