Selected Answer
Hi again.
Your attached file removed so in my version (attached) you'll need to change CustomerItems cells D4:D6 to locations with your test image files (since I changed them so I could test). I've corrected the G2 selection issue however (as per separate question).
In the Equip_LoadPic() sub, I think there are two problems: you use SelRow to pick up the pre-written image path from CustomerItems but it can refer to an emply cell (e.g. P6 for Sylv, Floye). I think it should read D (not L).
Also you set the picture height to acell height- it could be squashed so I commented that out. These are changed in bold below and in the attached file:
PicPath = Sheet12.Range("D" & EquipRow).value 'Picture Path '### was L not D
If Dir(PicPath, vbDirectory) <> "" Then 'Picture Path Exists
'With .Pictures.Insert(PicPath)
' With .ShapeRange
' .LockAspectRatio = msoTrue
' .Height = 150
' .Name = "EquipPic"
' End With
ActiveSheet.Pictures.Insert(PicPath).Select
With Selection.ShapeRange
.LockAspectRatio = msoFalse
.Left = Sheet11.Range("L" & SelRow).Left
.Top = Sheet11.Range("L" & SelRow).Top
.Width = Sheet11.Range("L" & SelRow).Width
'.Height = Sheet11.Range("L" & SelRow).Height' ### don't use cell height or image is squashed into a cell
End With
Also, you mentioned before multiple images- I haven't seen (in the time I had) where you delete images from a previous selection in G2.
REVISION 1: In the second file attached (Myworkbook Picture Issue v0_a.xlsm) based on your recent revision, apart from the chnages above, columns A:B in TESTMAIN2 are unhidden and my test file locations appear in CustmerItems(please change)
in Worksheet_SelectionChange I've reinstated the line:
If Range("O" & Target.row).value <> "" Then Equip_LoadPic
In Equip_LoadPic, I've made a minor change so the shapes don't have the some name.
With Selection.ShapeRange
..
'.Height = Sheet11.Range("L" & SelRow).Height
.Name = "EquipPic" & SelRow 'don't call shapes the same thing!
End With
Now, for the case of "Mike, Floye" two images are loaded (but the second image aligned with cell L11 is hidden by that in cell L10. If I click in row 11 of the table however, the second image is brought to the front and so visible. Not sure if that's what you want.
You still need to change your macros to delete the pictures loaded from previous G2 selections which have loaded images.
Revision 2: Firstly I've corrected the renaming of shapes in the code I added above (I didn't spot that the double inverted comma was at the end of the line so the intended comment was part of the shape name!).
Now loaded images have unique names liked EmpPic10, EmpPic11 etc. so the (With Sheet11) .Shapes("EmpPic").Delete doesn't work, as you say. I've commented out that line in the sub Equip_LoadPic() and instead changed Sheet11 sub to include the bits in bold below (which cycle through shapes and delete any like EmpPic10, EmpPic11 etc.):
Private Sub Worksheet_Change(ByVal Target As Range)
'Application.ScreenUpdating = False
Dim EmpRow As Long, Sp As Shape
If Not Intersect(Target, Range("G2")) Is Nothing Then
If Range("G2").value <> Empty And Range("B5").value <> Empty Then
For Each Sp In Sheet11.Shapes
If Sp.Name Like "EquipPic*" Then Sp.Delete
Next Sp
Empl_Load
End If
End If
If Not Intersect(Target, Range("J2")) Is Nothing And Range("B5").value <> "" Then Order_Load
End Sub
This means that if G2 changes, the old images are deleted before any new images are loaded (this wasn't happening with the now-deleted delete statement in Equip_LoadPic if the G2 selection had no matching image files listed).
The new file should be okay now.