Technology

Instructions on how to insert image links into Excel

Quoc Duong March 18, 2025 14:51

Inserting image links into Excel will help viewers quickly navigate to the website containing the image if they click on the link. You can also insert one or more images into an Excel cell when you need to make a list with images.

Instructions on how to insert a link into an existing image in Excel

Step 1:To insert a photo link into Excel, first you need to open the website containing the image you need to insert the link into Excel. Then right-click on that image and selectCopy image address.

Step 2:Next, open the Excel file where you want to insert the image link. Then right-click on the location where you want to insert the image link. When the scroll bar appears, select the itemLink.

Step 3:At this time, the Insert Hyperlink dialog box appears. Click on the itemExisting File or Web Page. Then go to the side menu column and click on the itemBrowsed PagesNow you need to paste the copied image link into the section.Address. After entering, pressOKto insert image link.

Step 4:After successfully inserting the link, move the mouse to the cell where the link was inserted and the image link will appear.

If you want to open that image, just left click on that link. The website containing that image will be opened quickly.

Instructions on how to insert image links into Excel using VBA

Press Alt + F11 to open the Visual Basic for Applications (VBA) Editor.

Go to Insert > Select Module.

Enter the following VBA code into a new module:

Sub InsertImageFromURL() Dim ws As Worksheet Dim imageURL As String Dim pic As Object Dim rng As Range ' Select sheet and cell containing image URL Set ws = ActiveSheet Set rng = ws.Range("A1") ' Replace A1 with cell containing image link ' Get image link from cell imageURL = rng.Value ' Check if cell has valid URL If imageURL = "" Then MsgBox "Cell does not contain image link!", vbExclamation, "Error" Exit Sub End If ' Add image to Excel Set pic = ws.Pictures.Insert(imageURL) ' Align image size according to cell With pic .ShapeRange.LockAspectRatio = msoFalse .Left = rng.Left .Top = rng.Top .Width = rng.Width .Height = rng.Height End With ' Free memory Set pic = Nothing Set ws = Nothing Set rng = Nothing End Sub

Put the image link in cell A1 (or another cell, but you have to change rng = ws.Range("A1") in the code).

Back in the Excel window, press Alt + F8, select InsertImageFromURL, and then press Run.

The image will be automatically downloaded and displayed in cell A1.

This VBA code works on Excel 2016 and above.

If you want the image to automatically display when you enter a link, you can assign a macro to Worksheet_Change to run automatically.

Featured Nghe An Newspaper

Latest

x
Instructions on how to insert image links into Excel
POWERED BYONECMS- A PRODUCT OFNEKO