how to have a pictue appear when option selected in combo bo

aamershaikh

New Member
Joined
Apr 30, 2006
Messages
1
hey des any one no how to create some sort of macro where when i choose an option in a combo the corresponding picture for it, appear next to the combo bo.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi, and welcome to Mr. Excel!!

I've not got much time, and I won't be available for a few days for any more help, but this should start you off, then you can adapt it for your own needs.

I've started a new workbook.
On sheet1 I've made a simple list: the word apple in A1, and orange in A2.

I've downloaded a picture of an apple to the c drive, and called it apple.jpg
I've downloaded a picture of an orange to the c drive, and called it orange.jpg (not very inspiring is it!!)
I've created a combobox (from the controlbox toolbar) called combobox1, on sheet1.
I've created an image (from the controlbox toolbar) on sheet1 called image1, and positioned it where I want relative to the combobox. Size it at this stage if you wish, as well.
In the properties section of the combobox, I've set the list fill range to A1:A2.

In design mode on sheet1, I've right-clicked the combobox, and selected "view code".
The code needs to read thus (copy and paste if you like):
Code:
Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "apple" Then
Me.Image1.Picture = LoadPicture("C:\apple.jpg")
Else
Me.Image1.Picture = LoadPicture("C:\orange.jpg")
End If
End Sub
Now, when you select a fruit from the combobox, the appropriate picture should populate image1.
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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