Userform Listbox Value help.

BMRC

New Member
Joined
Feb 8, 2008
Messages
21
Hi all, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
I have a userform with a listbox and some options buttons. <o:p></o:p>
<o:p></o:p>
the user will select an item from the listbox, select their option (Add, Remove, Edit, View). Their selection helps define the values and actions of userform2, which changes and populates info accordingly. <o:p></o:p>
<o:p></o:p>
Where I am running into trouble is I want to populate a custom warning message or error message if they forget to select either an item from the list or an option. How do I trigger a warning if nothing is selected from the listbox (BS1StyleList) ?<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
<CODE><o:p></o:p>
Private Sub BS1Confirm_Click()
Application.ScreenUpdating = False
'Remove Warning
If BS1Remove = True Then Warn.Show vbModeless
'No Option selected Warning
If BS1Add = False And BS1Remove = False And BS1Edit = False And BS1View = False Then Warn.Show vbModeless<o:p></o:p>


'No Item Selected Warning
If BS1StyleList = Null Then Warn.Show vbModeless
<o:p></o:p>

'No Warning => goto Edit form
If BS1Add = True Or BS1Edit = True Or BS1View = True Then BSEdit.Show vbModeless

Application.ScreenUpdating = True
End Sub<o:p></o:p>

</CODE><o:p></o:p>
<o:p></o:p>
I've tried a few different ways and can't get one to work. Any help would be much appreciated. <o:p></o:p>
Thanks!<o:p></o:p>
BMRC<o:p></o:p>
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
The easiest way to check if nothing has been selected is to look at the ListIndex property.

If it's -1 nothing has been selected, if an item has been selected then it's value will correspond to the item's index in the list, starting at 0 for the 1st item.

By the way what exactly are you doing with the Add/Edit/View/Whatever options?

For example, are you actually doing the same thing if Add/Edit are selected for example?
 
Upvote 0
That's perfect. Thanks for your help!

Add and Edit are both pointing to the same userform, but I am using that option selection to alter what Userform_Initialize is doing.

For example:

Code:
        If Userform1.BS1Add = True Then
        BSE2Add.Visible = True
        BSE2Confirm.Visible = False
        BSE2Edit.Visible = False
        BSE2View.Visible = True
        End If
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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