I have code that works for creating a drop-down list on a WORKSHEET that allows you to select multiple items... can this also be done on a USERFORM?

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
458
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I found this code after searching for some VBA that would could create a drop-down selection box that would allow you to select up to THREE different selections (selecting multiple items from the list.)

I found this code that does exactly that:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'
Dim Oldvalue As String
Dim Newvalue As String
'
On Error GoTo Exitsub
    If Target.Address = "$C$2" Then
        If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
            GoTo Exitsub
        Else: If Target.Value = "" Then GoTo Exitsub Else
            Application.EnableEvents = False
            Newvalue = Target.Value
            Application.Undo
            Oldvalue = Target.Value
                If Oldvalue = "" Then
                    Target.Value = Newvalue
                Else
                    Target.Value = Oldvalue & ", " & Newvalue
                End If
        End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
End Sub


examples of the code in use:

Capture36.JPGCapture37.JPGCapture38.JPG

I think I understand how its working in order to do this, but because the code operates from a worksheet (including data validation from a range of cells on a worksheet), I cant see how I could modify this to possibly work on a userform drop-down selection list like I have on a userform... (or if something like this is even possible(?) )

example current userform drop down box:
Capture40.JPG
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Thank you. I dont (at least initially) like the way the list box looks and populates, but I think I can make it work... IF I can change a few of its properties the way I need it to. Since this would be an unrelated question to my original question, I will mark this one complete and will post a new question. Thank you for the reply.
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

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