VBA posting image to worksheet (im so close)

brandonkw

New Member
Joined
Dec 13, 2016
Messages
2
Hey So i have a matrix of URLs, they are in columns K L M N. Not every cell has a URL some are blank. Ideally i would like to print the image to the cell the URL is in and resize to thumbnail size.

Using some of the code on this site ive managed to get the first column working well. However when i try to 'replicate' it on column L it just does nothing. K works and i dont get an error code but it never gets the L images.

Anyone know where im messing up? I'm pretty noob at VBA really just copy pasting and trying to work through it logically but guess im missing a piece. Any help would be greatly appreciated!!

Sub IMAGE()
Dim Rng As Range
Dim Cell As Range
Dim Pic As picture
Application.ScreenUpdating = False
Columns("k:k").ColumnWidth = 21.29
Set Rng = Range("K3:K" & Range("k" & Rows.Count).End(xlUp).Row)
For Each Cell In Rng
With Cell
On Error Resume Next
Set Pic = .Parent.Pictures.Insert(.Value)
If Err <> 0 Then
Err.Clear
Else
With .Offset(0, 0)
Pic.Top = .Top
Pic.Left = .Left
Pic.Height = .Height
Pic.Width = .Width
End With
End If
On Error GoTo 0
End With
Next Cell

' not sure why this one isnt working......
Columns("l:l").ColumnWidth = 21.29
Set Rng = Range("L3:L" & Range("L" & Rows.Count).End(xlUp).Row)
For Each Cell In Rng
With Cell
On Error Resume Next
Set Pic = .Parent.Pictures.Insert(.Value)
If Err <> 0 Then
Err.Clear
Else
With .Offset(0, 0)
Pic.Top = .Top
Pic.Left = .Left
Pic.Height = .Height
Pic.Width = .Width
End With
End If
On Error GoTo 0
End With
Next Cell

Rows("3:11").RowHeight = 153
Application.ScreenUpdating = True
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top