Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show image from folder based on cell value in MS Excel

Tags:

excel

image

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?

like image 378
s.k.paul Avatar asked Nov 01 '22 03:11

s.k.paul


1 Answers

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
like image 169
Kᴀτᴢ Avatar answered Nov 08 '22 04:11

Kᴀτᴢ