+ Reply to Thread
Results 1 to 6 of 6

Macro Drop Down Box

  1. #1
    Registered User
    Join Date
    05-26-2005
    Posts
    56

    Macro Drop Down Box

    I currenly have a macro that runs and ends with an input box popping up asking the user to enter yes or no. It goes as follows:

    Range("N53").Value = InputBox("Yes or No")

    However, as this is an input box the text is a free field and the yes or no is just a title. To avoid errors on input (ie people pressing Y for yes) i want this input box to be a drop down box, or i only want the user to be able to select the options i offer.

    Any thoughs

  2. #2
    Bob Phillips
    Guest

    Re: Macro Drop Down Box

    Why not use a MsgBox

    If MsgBox("Select Yes or No", vbYesNo) = vbYes Then
    Range("N53").Value = "Yes"
    Else
    Range("N53").Value = "No"
    End If

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "chalky" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I currenly have a macro that runs and ends with an input box popping up
    > asking the user to enter yes or no. It goes as follows:
    >
    > Range("N53").Value = InputBox("Yes or No")
    >
    > However, as this is an input box the text is a free field and the yes
    > or no is just a title. To avoid errors on input (ie people pressing Y
    > for yes) i want this input box to be a drop down box, or i only want
    > the user to be able to select the options i offer.
    >
    > Any thoughs
    >
    >
    > --
    > chalky
    > ------------------------------------------------------------------------
    > chalky's Profile:

    http://www.excelforum.com/member.php...o&userid=23758
    > View this thread: http://www.excelforum.com/showthread...hreadid=501107
    >




  3. #3
    Kurt Barr
    Guest

    RE: Macro Drop Down Box

    One way to do it would be to use a ComboBox instead of a TextBox.

    "chalky" wrote:

    >
    > I currenly have a macro that runs and ends with an input box popping up
    > asking the user to enter yes or no. It goes as follows:
    >
    > Range("N53").Value = InputBox("Yes or No")
    >
    > However, as this is an input box the text is a free field and the yes
    > or no is just a title. To avoid errors on input (ie people pressing Y
    > for yes) i want this input box to be a drop down box, or i only want
    > the user to be able to select the options i offer.
    >
    > Any thoughs
    >
    >
    > --
    > chalky
    > ------------------------------------------------------------------------
    > chalky's Profile: http://www.excelforum.com/member.php...o&userid=23758
    > View this thread: http://www.excelforum.com/showthread...hreadid=501107
    >
    >


  4. #4
    Registered User
    Join Date
    05-26-2005
    Posts
    56
    The msgbox idea worked perfectly thanks! One think i wanted to add though was further options, ie yes, no, maybe (amongst others).

    Any ideas on how this would work? I can't say i am familiar with the combobox.

    Thanks for your help so far

    chris

  5. #5
    Bob Phillips
    Guest

    Re: Macro Drop Down Box

    I am afraid that you cannot have Maybe as this technique uses built-in
    buttons, but you could use Cancel

    Dim ans As Long
    ans = MsgBox("Select Yes or No", vbYesNoCancel)
    If ans = vbYes Then
    Range("N53").Value = "Yes"
    ElseIf ans = vbNo Then
    Range("N53").Value = "No"
    Else
    Range("N53").Value = "Maybe"
    End If



    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "chalky" <[email protected]> wrote in
    message news:[email protected]...
    >
    > The msgbox idea worked perfectly thanks! One think i wanted to add
    > though was further options, ie yes, no, maybe (amongst others).
    >
    > Any ideas on how this would work? I can't say i am familiar with the
    > combobox.
    >
    > Thanks for your help so far
    >
    > chris
    >
    >
    > --
    > chalky
    > ------------------------------------------------------------------------
    > chalky's Profile:

    http://www.excelforum.com/member.php...o&userid=23758
    > View this thread: http://www.excelforum.com/showthread...hreadid=501107
    >




  6. #6
    Registered User
    Join Date
    05-26-2005
    Posts
    56
    Thanks for your reply, i will look into how this might be incorporated. I am pretty sure it will keep things ticking over for the time being.

    Thanks
    chris

+ 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