+ Reply to Thread
Results 1 to 8 of 8

Limiting Input Box Selections

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003
    Posts
    107

    Limiting Input Box Selections

    I currently have an input box that asks for a user to enter their intials. Is there a way to make sure that the initials they entered are of a valid user. I only have about 6 people that use this. I would like it to check their input against the list and then if its not right make them enter them again.

    Sender = InputBox("Please Enter Your initials:")
    Example: CJH, PHT, FXH, TOM

    If the entry is not one of those then I would like it to ask them to input again.

    Once the input is made it outputs to a log sheet for me.

    Windows("RCSN Log.xls").Activate
    Sheets("Log").Select
    ActiveSheet.Cells(ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row + 1, "A").Value = Sender
    ActiveSheet.Cells(ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row + 1, "B").Value = SendDate
    ActiveSheet.Cells(ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row + 1, "C").Value = SendTime
    I would then like a yes/no input box that asks them a question. If they enter yes I would like it to output to the log. If they enter no I want it to just continue on with the rest of the macro.
    Last edited by CJPHX; 07-21-2010 at 05:38 PM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Limiting Input Box Selections.

    The following code will accomplish what you are seeking:

    Public Sub CJPHX()
    
    Dim arrInitials(3) As String
    Dim i As Integer
    Dim blnfound As Boolean
    
    blnfound = False
    arrInitials(0) = "CJH"
    arrInitials(1) = "PHT"
    arrInitials(2) = "FXH"
    arrInitials(3) = "TOM"
    
    Sender = InputBox("Please Enter You Initials:")
    For i = 0 To UBound(arrInitials())
        If arrInitials(i) = Sender Then blnfound = True
    Next i
    
    If blnfound = False Then
        MsgBox "Invalid Initials"
        Exit Sub
    End If
    
    End Sub
    You could also set up a custom form with a listbox with all your expected user's initials, and let them select them from the list.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: Limiting Input Box Selections.

    I have tried to use the user form's before and I get some error about it not being available. I am hoping once my company upgrades to 2007 in the next few months it will be available.

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Limiting Input Box Selections.

    Here is an example with a userform and listbox. Does this now work on your machine?
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: Limiting Input Box Selections.

    It won't let me click on the show form button.

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Limiting Input Box Selections.

    Wow, I've never heard of a version of excel that doesn't allow the use of userforms.
    Anyway, did the code I posted above work for you?

  7. #7
    Forum Contributor
    Join Date
    05-19-2010
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2003
    Posts
    107

    Re: Limiting Input Box Selections.

    It has so far. I am trying to tweak it a little to work for the next box under it. I don't want to post that question under this one. Should I start a new thread? Or since it relates to the same thing post it here?

  8. #8
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Limiting Input Box Selections.

    If it's a new question, I guess you could start a new thread with a link to this one.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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