How to Convert Image URLs to Actual Images in Excel?


Sometimes in Excel, you could have faced a problem where you were provided with image URLs instead of images. If we want to get the images manually, then it can be a lengthy process. So, we need a faster process to complete it. This tutorial will help you understand how we can convert image URLs to actual images in Excel. We can complete this task with the help of a VBA application, as it can’t be completed directly in Excel.

Convert Image URLs to Actual Images in Excel

Here we will first create a VBA module and then run it to insert the images into the sheet. Let's go over a simple procedure for converting image URLs to actual images in Excel using the VBA application.

Step 1

Let us consider an Excel sheet that contains a list of image URLs similar to the below image.

Now right-click on the sheet name and select View Code to open the VBA application.

Right click > View code

Then in the VBA application, click on Insert and select Module.

Inset > Module

Step 2

Then type the below-mentioned programme into the text box as shown in the below image.

Program

Sub URLPictureInsert() 'Updated By Nirmal Dim Pshp As Shape Dim xRg As Range Dim xCol As Long On Error Resume Next Application.ScreenUpdating = False Set Rng = ActiveSheet.Range("A2:A5") 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 If .Width > xRg.Width Then .Width = xRg.Width * 2 / 3 If .Height > xRg.Height Then .Height = xRg.Height * 2 / 3 .Top = xRg.Top + (xRg.Height - .Height) / 2 .Left = xRg.Left + (xRg.Width - .Width) / 2 End With lab: Set Pshp = Nothing Range("A2").Select Next Application.ScreenUpdating = True End Sub

In the program, A2:A5 is the range of image URLs.

Step 3

Now save the sheet as a macro-enabled workbook and click F5 to run the code, and the images will appear automatically as shown in the below image.

Conclusion

In this tutorial, we used a simple example to demonstrate how you can convert mage URLs to actual images in Excel.

Updated on: 24-Feb-2023

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements