I have a statement with Image Dynamically In Cell (fom I11 to I19) I usually only use 2 or 3 lines, so the other 7-8 are empty. My macro command works fine in cells that are filled, but for empty cells it also inserts an image that says "The linked image cannot be displayed". I would like VBA not to insert an image if cell D11 to D19 is empty. Also, to run the command I have to click on the developer tab and macros, can this be automated (column D has data validation)?. Thank you
CODE:
Sub Insert_Multiple_Images()
Set Image_Names = Range("D11:D19")
Image_Location = "C:\Image"
Image_Format = ".png"
Set Cell_Reference = Range("I11:I19")
For i = 1 To Image_Names.Rows.Count
For j = 1 To Image_Names.Columns.Count
Set Image = ActiveSheet.Pictures.Insert(Image_Location + "" + Image_Names.Cells(i, j) + Image_Format)
Image.Top = Cell_Reference.Cells(i, j).Top
Image.Left = Cell_Reference.Cells(i, j).Left
Image.ShapeRange.Height = 45
Image.ShapeRange.Width = 75
Next j
Next i
End Sub
Bookmarks