I created a code to insert pictures into a cell from a link (next to that cell). Sometimes a picture is deleted in the file it links to. I get an error 400, but when I put 'on error resume next' it leaves the last cell with a right link empty and puts that picture in the cell with a wrong link. Also the last cell with a right link is empty.
The position of 'on error resume next' does not matter (before loop, or at any place in the loop)
How can I avoid that? Just skip the wrong link and put pictures at the right positions?
Sub InsertPictures()
Call DeleteAllPicturesInRange
Dim pic As String
Dim myPicture As Picture
Dim rng As Range
Dim cl As Range
Set rng = Range("J5:J124")
For Each cl In rng
pic = cl.Offset(0, 1)
Set myPicture = ActiveSheet.Pictures.Insert(pic)
With myPicture
.ShapeRange.LockAspectRatio = msoFalse
.Width = cl.Width
.Height = cl.Height
.Top = Rows(cl.Row).Top
.Left = Columns(cl.Column).Left
End With
Next
End Sub
On Error Resume Next
unless you know what the error is! - SierraOscar