Consulting

Results 1 to 8 of 8

Thread: Solved: Select Case

  1. #1
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location

    Solved: Select Case

    hi,

    i have the following code which works fine the way it is.
    the data is referenced on a sheet A5:A62. Is there a way to reference this?
    I tried Case Range ("A5:A62") but that didn't work

    [vba]
    For x = 9 To 17
    Select Case Sess0.Screen.GetString(x, 4, 2)
    Case "NEW YORK", "NEW JERSEY", "RHODE ISLAND", "VIRGINIA", _
    "WEST VIRGINIA", "CALIFORNIA", "ALASKA", "ARKANSAS"
    If ...
    End if
    end select
    next x
    [/vba]

    thanks
    zach

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    zach

    If you mean that A5:A62 contains New York etc the answer is no.

    Are you actually sure Select Case is the best way to do this?

    You only appear to have one Case statement.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,478
    Location
    I think the Match function may be the way to go.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    hi,
    i want my end user to have the flexibility to input the states for querying the mainframe.
    the way i have it set up now, i would need to change the coding each time. so i thought that maybe i can have the user input the states that they want and i can have the code reference that range.
    i guess Select Case might not be the way to go then.
    could i use the match function for this? how would i do this?

    zach

  5. #5
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    zach

    I think we need more information.

    What exactly are you doing?

    How are you 'querying' the mainframe?

    How are you getting user input?

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    .. and most importantly, what is the scope/purpose of this? Tell us what you're trying to accomplish in the end.

  7. #7
    VBAX Regular
    Joined
    Feb 2005
    Location
    North West London, UK
    Posts
    19
    Location
    Perhaps something along these lines might help:



    http://www.asdy88.dsl.pipex.com/Experts%20Exchange/USAStates.xls
    Last edited by mvidas; 10-05-2006 at 11:53 AM. Reason: fixed hyperlink

  8. #8
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    thanks patrick for the coding; it's back to the drawing board with this one

Posting Permissions

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