VBA Inserting Picture From File with Loops [Closed]

Report
Posts
1
Registration date
Monday February 13, 2017
Status
Member
Last seen
February 13, 2017
-
Help please?

I am using the below code to insert a picture from a file based on the value of a cell. I just need it to repeat this for every row. Also I need to make sure the picture stays if the sheet is sent somewhere else that does not have access to the I:\ on our network. Can someone help me please? I am very new to VBA, I have just been doing a lot of googling.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A2")) Is Nothing Then Exit Sub
Dim myPict As Picture

With Range("B2")
Set myPict = Range("B2").Parent.Pictures.Insert("I:\Presenter\Images\" & Target.Value & ".jpg")
myPict.Top = .Top
myPict.Width = .Width
myPict.Height = .Height
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
End With

End Sub

Thanks
Eve

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!