Inserting photo into userform using a variable

billyshears

Board Regular
Joined
Aug 29, 2013
Messages
61
My userform has a photo area.

I want the userform to operate so when I click the button to bring it up, the photo that comes up with the userform to be based on a cell value on the active worksheet.

For instance, when Cell A1 = 1, I click a button and the userform brings up Photo1.jpg and shows a picture of a flower

When Cell A1=5, the userform brings up Photo5.jpg and shows a picture of a lion

Any answers are much appreciated.
 

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.
I believe I am close with this

UserForm1.Image1.Picture = LoadPicture("C:\Users\mambr\OneDrive\Documents\Owen Game\Picture" & "Range("C5").Value" & ".jpg")

but part of this must be off. It works if I simply use the full path, but not with trying to do the variable
 
Upvote 0
The range portion seems off. It's not tied to a worksheet and it's in quotes. I'd try to change that part to

VBA Code:
Application.thisworkbook.worksheets("SheetName").cells(5,3).value
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,304
Members
448,564
Latest member
ED38

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