A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Here are two variations.
The first one inserts the image into the cells.
Sub InsertImages()
Const URLCol = "D"
Const ImgCol = "B"
Const FirstRow = 2
Dim LastRow As Long
Dim CurRow As Long
Application.ScreenUpdating = False
LastRow = Cells(Rows.Count, URLCol).End(xlUp).Row
On Error Resume Next
For CurRow = FirstRow To LastRow
If Cells(CurRow, URLCol).Value <> "" Then
' for some reason, InsertPictureInCell works only for the active cell
Cells(CurRow, ImgCol).Select
Selection.InsertPictureInCell PictureURI:=Cells(CurRow, URLCol).Value
End If
Next CurRow
Application.ScreenUpdating = True
End Sub
The second one inserts IMAGE formulas.
Sub InsertImages()
Const URLCol = "D"
Const ImgCol = "B"
Const FirstRow = 2
Dim LastRow As Long
Dim CurRow As Long
Application.ScreenUpdating = False
LastRow = Cells(Rows.Count, URLCol).End(xlUp).Row
On Error Resume Next
For CurRow = FirstRow To LastRow
If Cells(CurRow, URLCol).Value <> "" Then
Cells(CurRow, ImgCol).Formula = "=IMAGE(""" & Cells(CurRow, URLCol).Value & """)"
End If
Next CurRow
Application.ScreenUpdating = True
End Sub