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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

rjp

Board Regular
Joined
Jan 5, 2006
Messages
148
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.
 

Forum statistics

Threads
1,171,972
Messages
5,878,548
Members
433,351
Latest member
Cindy Little

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
Top