Forum Discussion
rickcoulter1
Sep 07, 2021Copper Contributor
Embedded images in Excel that populate when you scroll over the appropriate cell
I'm working with a spreadsheet that has multiple images in expanded format. I was hoping to only have the images appear when I scroll over the appropriate cell. Currently, there are too many images...
Juliano-Petrukio
Sep 07, 2021Bronze Contributor
Considering cell D2 with the image path you can type on E2 the following UDF
=AddCommentWithImage(D2)
Public Function AddCommentWithImage(ByRef ImagePath As String)
Dim rng As Range, cmt As Comment
Set rng = ActiveCell
If Not (rng.Comment Is Nothing) Then rng.Comment.Delete
Set cmt = rng.AddComment
cmt.Text Text:=""
With cmt.Shape
.Fill.UserPicture ImagePath
.Width = 481.5864
.Height = 359.7734
End With
End Function