I want to show image base on related cell value in Microsoft Excel.
For example,
A1 = "mypic.png"        B1 cell should show mypic.png 
A2 = "anotherpic.png"   B2 cell should show anotherpic.png
Pictures are in the same directory.
Is there any way to do it?
With this code you can insert a image in cell F20 with the path that is stored in cell A1. Use the full path like D:\one.jpg. Change Tabelle1 with your sheetname.
Sub Test()
    Dim objPicture As Picture
    With Tabelle1.Cells(20, 6) ' Picture starts in cell F20 -> change as you need 
        Set objPicture = .Parent.Pictures.Insert(Tabelle1.Cells(1, 1).Value)
        objPicture.Top = .Top
        objPicture.Left = .Left
        objPicture.Height = 150
        objPicture.Width = 150
    End With
End Sub
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With