I'm experimenting with a userform and change event and was wondering how you can add the ability to show an Image of what was selected, sort of a like an example of the item selected.
So I've create a userform with 2 Combo box's. The first lists the 'Groups' of Fruits, Animals, Cars. And the second then lists the items for each group. And the below works as expected.
Now I'm trying to figure how (if possible) to show in the userform an image of what what was selected. So if the user chose Animals, and then cat, they would get small 'example' image in the userform of a cat. Or perhaps provide a 'command button' to launch and open image in separate smaller window or user form?
This is the basis code thus far in setting up the userform and combo box's. But I'm not sure now on how to proceed.
I should add that I would probably prefer to include the image within the excel file/macro and believe you can use the Picture Property and to not have the files/images stored elsewhere on the users pc.
Private Sub ComboBox1_Change()
Dim index As Integer
index = ComboBox1.ListIndex
ComboBox2.Clear
Select Case index
Case Is = 0
'Fruits
With ComboBox2
.AddItem "Apple"
.AddItem "Banana"
.AddItem "Orange"
End With
Me.ComboBox2.Text = Me.ComboBox2.List(0)
Case Is = 1
'Animals
With ComboBox2
.AddItem "Dog"
.AddItem "Cat"
.AddItem "Mouse"
End With
Me.ComboBox2.Text = Me.ComboBox2.List(1)
Case Is = 2
'Cars
With ComboBox2
.AddItem "Dodge"
.AddItem "Ford"
.AddItem "Chevy"
End With
Me.ComboBox2.Text = Me.ComboBox2.List(2)
End Select
End Sub
Private Sub CommandButton1_Click()
Range("A1").Value = ComboBox2.Value
End Sub
Private Sub CommandButton2_Click()
Unload UserForm3
End Sub
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Fruits"
.AddItem "Animals"
.AddItem "Cars"
End With
Me.ComboBox1.Text = Me.ComboBox1.List(0)
End Sub
Bookmarks