Hi, humbly requesting assistance.
1. I have the code below which inserts a picture from a folder D:\CLLT\CLLT Images into "K4" based on the picture name in "P5". It works perfectly fine if I change "P5" manually.
2. How do I change the code if "P5" is an "if formula" which generates the filename and changes with other cell inputs to insert the picture from my folder whenever the formula in "P5" changes?
3. Also, how do I modify the code to delete only the .jpg pictures and not my ActiveX control boxes? (to delete pic every time the selection changes)
1. I have the code below which inserts a picture from a folder D:\CLLT\CLLT Images into "K4" based on the picture name in "P5". It works perfectly fine if I change "P5" manually.
2. How do I change the code if "P5" is an "if formula" which generates the filename and changes with other cell inputs to insert the picture from my folder whenever the formula in "P5" changes?
3. Also, how do I modify the code to delete only the .jpg pictures and not my ActiveX control boxes? (to delete pic every time the selection changes)
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myPict As Picture
Dim PictureLoc As String
If Target.Address = Range("P5").Address Then
ActiveSheet.Pictures.Delete
PictureLoc = "D:\CLLT\CLLT Images\" & Range("P5").Value & ".jpg"
With Range("K4")
Set myPict = ActiveSheet.Pictures.Insert(PictureLoc)
.RowHeight = 14.5
myPict.Top = .Top
myPict.Left = .Left
myPict.Placement = xlMoveAndSize
myPict.Height = 160
End With
End If
End Sub