Skip to content

Instantly share code, notes, and snippets.

@mcnemesis
Created August 11, 2016 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcnemesis/e1b2beb23d11c0948319538a3e0f72aa to your computer and use it in GitHub Desktop.
Save mcnemesis/e1b2beb23d11c0948319538a3e0f72aa to your computer and use it in GitHub Desktop.
Excel VBA Macro to insert image into a cell based on url in another cell
Sub InstallPictures()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim url_column As Range
Dim image_column As Range
'column with url...
Set url_column = Worksheets(1).UsedRange.Columns("AE")
'column where image will be inserted
Set image_column = Worksheets(1).UsedRange.Columns("AF")
Dim i As Long
For i = 2 To url_column.Cells.Count
Set Picture = image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)
Picture.Left = image_column.Cells(i).Left
Picture.Top = image_column.Cells(i).Top
Picture.Height = 40
image_column.Cells(i).EntireRow.RowHeight = 40
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
@DevopSpine
Copy link

This not getting the pictures from this URL
https://cdn.shopify.com/s/files/1/0965/5800/products/K5104-AF05-anvil-tt-pave-large-slider-with-chain.jpg?v=1541170590

any reason that why its not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment