inserting images into cell from url in adjacent cell

stuartnico

New Member
Joined
Jun 16, 2015
Messages
10
Hello

Calling the VBA Jedi Masters....

Code:
Sub GRABIMAGE()
Dim url_column As Range
Dim image_column As Range


Set url_column = Worksheets(1).UsedRange.Columns("A")
Set image_column = Worksheets(1).UsedRange.Columns("B")

Dim i As Long
For i = 1 To url_column.Cells.Count

  With image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)

    .Left = image_column.Cells(i).Left
    .Top = image_column.Cells(i).Top
    image_column.Cells(i).EntireRow.RowHeight = 120
 
  End With

Next
End Sub

I use excel 2007 - old but does the job.

Anyway this works to a degree it does seem to take sometime to run but I suspect this is more down to the poor power in my laptop.

It does seek out the URL in column A and Inserts the image into column B at the corresponding cell/row to the image URL.

The only bit that I'm struggling with is how to resize the images so that are scaled down to a thumbnail size.

I'm more into .php than VBA and as an old codger it takes a while for the penny to drop...lol

I cannot take credit for the above as I found it on the net not sure where tbh.
 
Last edited by a moderator:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Yippee

Figured it out....

Sub GRABIMAGE()
Dim url_column As Range
Dim image_column As Range


Set url_column = Worksheets(1).UsedRange.Columns("A")
Set image_column = Worksheets(1).UsedRange.Columns("B")

Dim i As Long
For i = 1 To url_column.Cells.Count

With image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)

With .ShapeRange
.LockAspectRatio = msoTrue
.Height = 25
End With

.Left = image_column.Cells(i).Left
.Top = image_column.Cells(i).Top
image_column.Cells(i).EntireRow.RowHeight = 25

End With

Next
End Sub

Just need to work out now how to deal with any images not present.
 
Upvote 0

Forum statistics

Threads
1,216,163
Messages
6,129,223
Members
449,495
Latest member
janzablox

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