List Box Item To Dialog Box - Help Please

snuggles79

New Member
Joined
Sep 25, 2006
Messages
8
I have created a userform for work using Excel.

On clicking the command button I need a box to pop up saying "Are you sure that [List Box Value] is the option you want? " If no then the user just goes back to the form to change the value and if yes then to continue with the macros

How can I do this please?

Many thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try this and let me know if you hit any trouble:

Code:
    'Assuming your ListBox is called lstTest
    Dim msgText As String
    Dim msgResponse As Integer

    msgText = "Are you sure that " & LstTest.List(LstTest.ListIndex) & " is the option you want?"

    msgResponse = MsgBox(msgText, vbYesNo, "Put a title in here")

    If msgResponse = vbYes Then
        'Carry on with the code
    Else
        'It's up to you, maybe just Exit Sub?
    End If

LstTest.ListIndex returns the index number of the currently selected item.
 
Upvote 0

Forum statistics

Threads
1,215,447
Messages
6,124,907
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top