The below code
• loops through each cell in the selected range
• reads the filename from that cell
Note: if the file name does not include the file extension you'll need to append it within the code
• inserts the referenced picture in the cell, at the location you set as FilePath, to the right of the cell:
• resizes the height and width of the picture to the cell's height
Sub InsertPicFromFile()
Dim cCell As Range
Dim FilePath As String
FilePath = "C:\Users\Me\Desktop\"
For Each cCell In Selection
If cCell.Value <> "" Then
On Error Resume Next
ActiveSheet.Shapes.AddPicture _
Filename:=FilePath & cCell.Value, LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=cCell.Offset(ColumnOffset:=1).Left, Top:=cCell.Top, _
Width:=cCell.Height, Height:=cCell.Height
End If
Next cCell
End Sub
Is that something you can work with?
Bookmarks