DataBlake
Well-known Member
- Joined
- Jan 26, 2015
- Messages
- 781
- Office Version
- 2016
- Platform
- Windows
Hello all,
So KuTools has this code which i've adapted for my needs, and when i run through the code with F8 I'm unsure of where it messes up.
I have 3 columns of image url's (some cells are blank) I set the range to the first column with images which is column B
I want it to insert the images to the column to the right of the range (column C)
can anyone point out where this isn't working as intended?
It runs but does nothing/inserts nothing
So KuTools has this code which i've adapted for my needs, and when i run through the code with F8 I'm unsure of where it messes up.
I have 3 columns of image url's (some cells are blank) I set the range to the first column with images which is column B
I want it to insert the images to the column to the right of the range (column C)
Code:
Sub URLPictureInsert()
'Updateby Extendoffice 20161116
Dim Pshp As Shape
Dim xRg As Range
Dim xCol As Long
Dim lastrow As Long
lastrow = Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
Application.ScreenUpdating = False
Set Rng = ActiveSheet.Range("B:B" & lastrow)
For Each cell In Rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select
Set Pshp = Selection.ShapeRange.Item(1)
If Pshp Is Nothing Then GoTo lab
xCol = cell.Column + 1
Set xRg = Cells(cell.Row, xCol)
With Pshp
.LockAspectRatio = msoFalse
.Width = 100
.Height = 100
.Top = xRg.Top + (xRg.Height - .Height) / 2
.Left = xRg.Left + (xRg.Width - .Width) / 2
End With
lab:
Set Pshp = Nothing
Range("B2").Select
Next
Application.ScreenUpdating = True
End Sub
can anyone point out where this isn't working as intended?
It runs but does nothing/inserts nothing