Change Image Control using Data Validation Worksheet Change with pictures from my WorkBook

goncalocoelho

New Member
Joined
Apr 15, 2020
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Hi!
I'm currently having some questions on how to make this work without having my VBA code to loadpictures from an external file.
I have set and Active X control Image to display different pictures according to a cell value. I would like to know if its possible to make the image box display pictures that are already in my excel sheet without it having to specify a LoadPicture command with an path to a file. My idea is having a hidden sheet with all the pictures i needed.


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$D$2" Then
    If Folha4.Range(Target.Address) = "Option1" Then
        Folha4.Image1.Picture = LoadPicture("path")
        
    If Folha4.Range(Target.Address) = "Option2" Then
        Folha4.Image1.Picture = LoadPicture("path")
        
    End If
End If
End Sub

1588862114762.png
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
With only two options, you can simply place two image controls on a separate sheet, each having their respective pictures. Then you can easily load a picture onto your image control from another image control using the Picture property...

VBA Code:
worksheets("Sheet1").Image1.Picture = worksheets("Sheet2").Image2.Picture

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,449
Members
448,966
Latest member
DannyC96

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