Picture appear when certain drop down list info selected.

leaper1981

New Member
Joined
Aug 16, 2019
Messages
27
Hi,

Just wondering if anyone can help at all. I have a sheet with a drop down list & another sheet with pictures that relate to each of the options in the drop down list on the main sheet. I want the pictures to appear in a box next to the drop down list when a certain one is selected. I did see a tutorial but it seemed to have the pictures on the same sheet whereas I want to keep the pictures on a different sheet. Not sure if I've done a good enough job of explaining here but I'm sure its very simple for someone that understands this better. Any help would be great. I've included pictures, the drop down list is on the main document shhet & the pictures are on a separate 'data' sheet.......im calling it.

Thanks in advance.

Dan
 

Attachments

  • Capture.JPG
    Capture.JPG
    30.2 KB · Views: 25
  • Capture1.JPG
    Capture1.JPG
    37.1 KB · Views: 16

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Please try the following on a copy of your workbook. It's a worksheet_change event module so you need to put it in the sheet module of the sheet where you want the pictures to go. Right click the sheet tab, select View Code and put the code in the window that appears on the right of screen.
I've called the sheet with the pictures "data" - change this in the code to the actual sheet name.
I've assumed the dropdown cells are B3 and B11 - again change these to suit. Also assumed the top left cells to put the pictures are D2 and D10 respectively, change to suit.
The code works if and only if you give the pictures on the second sheet the exact same names as the dropdown choices.
The code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Not Intersect(Range("B3,B11"), Target) Is Nothing Then
        Application.EnableEvents = False
        Dim img As Object, pick As String, x As String
        pick = Target.Value
        Set img = Worksheets("data").Shapes(pick) '<-- *** change to sheet name where pictures are ***
        x = Target.Value
        
        On Error Resume Next
        Me.Shapes(x).Delete
        On Error GoTo 0
        
        If Target.Address = ["$B$3"] Then
            img.Copy
            Me.Paste [D2]
            [B3].Select
        ElseIf Target.Address = ["$B$11"] Then
            img.Copy
            Me.Paste [D10]
            [B11].Select
        End If
    End If
    Application.EnableEvents = True
End Sub

Link to demo file: picture copy.xlsm
 
Upvote 0
Hi Kevin,

Thanks for your reply, I'm sorry for being very poor at giving the correct information. I really tried to make the changes to the cells I've actually used (which I can do) but I think I really messed you about by not showing exactly how I had set it up (which might not be the best way). I think it won't work for me as my drop down list is on a different tab.
So I've now included pictures that show the cells and tabs! which probably makes it a lot easier.

I have the main document I want the customer to use (SAMPLE REQUEST) tab, then the drop down list for the styles is on the (DATA) tab, and the pictures are on the (CARTONS&FITMENTS) tab.

The only difference from your (picture copy) I would like is that the drop down info isn't on the Sheet1 tab (in your example), rather on the data tab (so its sort of hidden) One other thing, I'm not sure why but although your example looks perfect the drop downs don't work when I try them, not sure why.

Lastly, why can't actual excel documents be shared on here? I only ask as I'm sure you'd do this in 2 secs if I could of sent it to you.

Anyway, again sorry for not giving all the info from the off, if you can help again at all that would be amazing.

Thanks again,
Dan
 

Attachments

  • Cartons&fitments.JPG
    Cartons&fitments.JPG
    47.1 KB · Views: 23
  • DATA.JPG
    DATA.JPG
    60.5 KB · Views: 19
  • Sample Request.JPG
    Sample Request.JPG
    68.2 KB · Views: 15
Upvote 0
It was really just a matter of changing the cell & sheet references for it to work. The code below is based on your new images. Here's the link to the updated file: picture copy.xlsm
You can't upload a file to the forum, but you can post useful copies of your sheets using the XL2BB add in, and you can also share your file(s) via Google Drive (as I have done) Dropbox, os=r similar file sharing platform.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Not Intersect(Range("B43,B51"), Target) Is Nothing Then
        Application.EnableEvents = False
        Dim img As Object, pick As String, x As String
        pick = Target.Value
        Set img = Worksheets("Carton&fitments").Shapes(pick)
        x = Target.Value
        
        On Error Resume Next
        Me.Shapes(x).Delete
        On Error GoTo 0
        
        If Target.Address = ["$B$43"] Then
            img.Copy
            Me.Paste [D42]
            [B43].Select
        ElseIf Target.Address = ["$B$51"] Then
            img.Copy
            Me.Paste [D50]
            [B51].Select
        End If
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0
Hi Kevin,

Happy new year, hope you had a good xmas!

Sorry I'm back with silly questions, I tried the last method you gave me but literally nothing happened, even when I changed the cell references to the correct ones it didnt even come back with an error. I know this will all be to do with the way I've done it so I've tried to use this (mini-sheet) to see if that allows you to see what I've done. Hoping this helps, I had to get rid of data when making a mini sheet as it said there were merged cells & it wouldn't do it.

PCI SR.xlsm
ABCDEFGHIJK
1
2CAD SAMPLE REQUEST FORM
3
4
5
6
7DATE:
8
9Project Managers Name:
10
11Project ID Reference:
12
13To provide a CAD sample we will require the following information
14
15Please provide the following dimensions of the vial
16
17
18
19
20
21Height of Vial Diameter of VialShoulder Height
22(Including cap)(Including Label)(Base to shoulder)
23
24
25Number of vials required?Temperature vials will be stored at?
26
27If you wish to pack an item that is not a vial please provide the dimensions and picture
28
29Paste picture here
30 Width of product:
31
32
33Height of product:
34
35
36Depth of product:
37
38
39Quantity required:
40
41
42
43Carton style required
44CLB
45
46
47
48
49
50
51Preferred fitment style
52
53
54
55
56
57
58
SAMPLE REQUEST
 
Upvote 0
wasnt sure if I could post 3 mini sheets in one message so I've sent them separately

PCI SR.xlsm
ABCD
1
2N/A
31
42
53
64
75
86
97
108
119
1210
1311
1412
1513
1614
1715
1816
1917
2018
2119
2220
2321
2422
2523
2624
2725
2826
2927
3028
3129
3230
33
34CLB
35CLB with fitment
36Peglock Tray
37Peglock with fitment
38RTE
39RTE with fitment
40OTE
41OTE with fitment
42Envelope base
43Envelope with fitment
44
45Style 1
46Style 2
47Style 3
48Style 4
49Style 5
DATA
 
Upvote 0
PCI SR.xlsm
ABC
1Carton StylesCarton photos
2CLB
3CLB with fitment
4Peglock Tray
5Peglock with fitment
6RTE
7RTE with fitment
8OTE
9OTE with fitment
10Envelope base
11Envelope with fitment
Carton&fitments
 
Upvote 0
The simplest way forward with this would be for you to share your actual file via Google Drive, Dropbox or similar file sharing platform. Otherwise we could be going back and forth indefinitely.
 
Upvote 0
Nope just realised that link requires you to sign in to my google account, sorry for being stupid I've got it in the google drive I'm not sure how to give it to you
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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