Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Test for column selection (97)

    In my application, the client enters a column letter (N to X) into an inputbox and the non-required columns within that range N to X are then deleted.

    In order to ensure that their entry is within this range (N to X), I need to capture their entry (fine, done that into a variable called 'client') then test this variable to ensure that the letter is correct.

    I thought of using the CASE...END SELECT method, but this means coding for uppercase as well as lowercase if the client enters a lowercase letter.

    for example:

    client = InputBox("Please enter the letter of the column (N-X) you wish to use", "Column Letter") [code to capture a blank entry]

    Select Case client
    Proc1:
    Case "N"
    GoTo Cont2
    Case "n"
    GoTo Cont2
    Case "O"
    GoTo Cont2
    Case "o"
    GoTo Cont2
    etc

    Case Else
    MsgBox "You must enter a column letter between N and X", vbOKOnly, "Column Letter Required"
    GoTo Proc1
    End Select
    Cont2:
    etc

    Is there a simpler way?

    Thanks in advance!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Test for column selection (97)

    Use

    client = UCase(InputBox(...))

    Whatever the user enters, client will contain an upper case value, so you don't need to handle upper and lower case separately. You can handle multiple letters in one go:

    Select Case client
    Case "N", "O", "R", "S"
    ' do something
    Case "P", "Q", "X"
    ' do something else
    Case Else
    ' catach-all for the rest
    End Select

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Test for column selection (97)

    Hans,

    Thanks very much - you must be setting some land speed records with your quick and helpful responses!

    Thanks again.

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Test for column selection (97)

    You might also want to check to make sure the user didn't enter more than one character.
    Legare Coleman

Posting Permissions

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