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
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,403
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!
 

Watch MrExcel Video

Forum statistics

Threads
1,118,754
Messages
5,574,040
Members
412,565
Latest member
roberttaekim
Top