+ Reply to Thread
Results 1 to 2 of 2

User Form - Msg Box based on answer in Combo Box

Hybrid View

  1. #1
    Registered User
    Join Date
    12-19-2020
    Location
    Alberta, Canada
    MS-Off Ver
    365
    Posts
    28

    User Form - Msg Box based on answer in Combo Box

    Hi Everyone,

    I'm new here and relatively new to VBA and I need some help with a project. I have looked far and wide for this solution without any luck so I'm hoping someone here will be able to lend a hand.

    I have a User form that allows for people to report unsafe conditions at work and the scale is from 1 to 4 on a hazard ranking scale.

    If the user selects 1 or 2 there's no need to prompt a Msg Box. If a user selects 3 then we would like a Msg Box to have a specific message. "You Must Report this to your Supervisor Immediately "

    If the user selects 4 we would like a Msg Box to have a unique message as well ""You Must Report this to The Plant Manager Immediately "

    Thank you in advance for your time and effort in helping me with this code.

    Kindest Regards
    Attached Files Attached Files
    Last edited by BigHungarian; 02-20-2021 at 02:15 PM. Reason: Solved

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: User Form - Msg Box based on answer in Combo Box

    Try adding this code to the userform module.
    Private Sub ComboBox1_Change()
    Dim strMsg As String
    
        Select Case ComboBox1.ListIndex
            Case 0, 1:
                ' do nothing
            Case 2:
                strMsg = "You Must Report this to your Supervisor Immediately "
            Case 3:
                strMsg = "You Must Report this to The Plant Manager Immediately "
        End Select
        
        If strMsg <> "" Then
            MsgBox strMsg, vbCritical, Replace(String(ComboBox1.ListIndex, "X"), "X", "Danger! ")
        End If
    
    End Sub
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Saving User Form Data to Row Based on Combo Box Selection
    By Skurski84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2020, 01:09 PM
  2. [SOLVED] Can user form fields be depenent upon the answer to another field?
    By aliciaward1001 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-20-2017, 09:43 AM
  3. Populate text boxes on user form, from combo box on same user form
    By Richardswaim in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 07-03-2016, 09:35 AM
  4. Choose Time Points Based on Values from Combo Box in User Form
    By Chaba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2014, 01:42 PM
  5. combo box user form code for two combo boxes
    By robert.begley1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-01-2012, 02:25 PM
  6. help with user form and combo box
    By TechRetard in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-01-2011, 04:56 AM
  7. Can't seem to get Combo Box on User Form
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-25-2005, 07:06 AM

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