HI All,
I am totally new to Macro and VBAs,
with the below code I am only able to insert pictures from a folder using a hyperlink on excel to retrieve the images
is some able to show me how
1 - I can amend the code in such a way that, when an image is not in the folder or the link is wrong, the code automatically moves on to the next cell underneath without stopping.
2 - How can I remove the link on those images and paste them as values so I can easily share the file for others to see them?
Here is the code
Sub InsertImageLineup()
Dim pic As String
Dim myPicture As Picture
Dim rng As Range
Dim item As Range
Set rng = Range("c4:c1000")
For Each item In rng
pic = item.Offset(0, -1)
If pic = "" Then Exit Sub
Set myPicture = ActiveSheet.Pictures.Insert(pic)
With myPicture
.ShapeRange.LockAspectRatio = msoFalse
.Width = item.Width
.Height = item.Height
.Top = Rows(item.Row).Top
.Left = Columns(item.Column).Left
.Placement = xlMoveAndSize
End With
Next
End Sub
Again i copied this code and was able to amend it in order to suit my needs.
Thanks
I am totally new to Macro and VBAs,
with the below code I am only able to insert pictures from a folder using a hyperlink on excel to retrieve the images
is some able to show me how
1 - I can amend the code in such a way that, when an image is not in the folder or the link is wrong, the code automatically moves on to the next cell underneath without stopping.
2 - How can I remove the link on those images and paste them as values so I can easily share the file for others to see them?
Here is the code
Sub InsertImageLineup()
Dim pic As String
Dim myPicture As Picture
Dim rng As Range
Dim item As Range
Set rng = Range("c4:c1000")
For Each item In rng
pic = item.Offset(0, -1)
If pic = "" Then Exit Sub
Set myPicture = ActiveSheet.Pictures.Insert(pic)
With myPicture
.ShapeRange.LockAspectRatio = msoFalse
.Width = item.Width
.Height = item.Height
.Top = Rows(item.Row).Top
.Left = Columns(item.Column).Left
.Placement = xlMoveAndSize
End With
Next
End Sub
Again i copied this code and was able to amend it in order to suit my needs.
Thanks