Do you need to change the destination URL, workbook reference, or the anchor text of a hyperlink in Excel? It would help if you learned how to edit Excel files or hyperlinks in Excel.
When your Excel workbook grows so much with datasets and needs external referencing, hyperlinking in Excel comes in handy. You can link one worksheet to another, one workbook to another, and even external websites or databases.
Excel also lets you update or edit those links to deal with broken links, update workbook references, or eliminate outdated website references. If you don’t know how to do all these, it’s completely cool! Just read this guide on Excel hyperlink editing to become a master of external reference management in Excel.
📒Read More: Check out this post on How to Remove Hyperlinks in Microsoft Excel!
Why Would You Want to Edit Links in Excel?
Find below why and when you might need to edit links in Excel:
- You often need to edit hyperlinks to correct errors in the destination address. For example, if a URL points to an outdated website, you can update it to the current portal.
- Customizing the display or anchor text is another major reason behind link editing in Excel. A hyperlink, like
https://www.howtoexcel.org/clear-all-filters/
may not look well on grid-based cells of Excel. You can replace this with an anchor text Clear All Filters to make it more readable and logical. - If the hyperlinks are as IP addresses and the DNS changed recently, you must edit and update it to quickly redirect the user to an external website and avoid DNS searching delays.
- Often you find that an employee or vendor changes the name of an Excel workbook to which another cell in another Excel file is dependent on fetching data for a formula. For example, the workbook reference
Budget2022.xlsx
was changed toBudget2023.xlsx
. This creates a broken link issue. You must edit the reference link to fix it. - External workbooks downloaded from third-party websites could contain malicious codes or links that you want to get rid of before using the Excel file. In this situation, you can manually edit those external reference links to make the Excel workbook safe.
Now, find below various methods and tricks to edit hyperlinks and workbook links in Excel:
Editing the Destination of Links in Excel
This is a major edit that you often need to make to keep external references always up to date. Find below two different ways to change the destination link in Excel:
Changing Hyperlinks on Excel Created Using Link To
If you added the hyperlinks in Excel cells by pressing Ctrl + K or right-click > Edit Hyperlink, follow these steps:
- Long-click the linked cell until the cursor changes to a cross from the hand-palm icon.
- Now, right-click or press Ctrl + K on the keyboard to get to the Edit Hyperlink dialog box.
- Delete the contents of the Address field in the dialog.
- Copy and paste the updated URL into the Address field.
- Click OK to save the changes made.
Modifying URLs in Excel Created Using the HYPERLINK Function
If you used the HYPERLINK formula to create linked cells or ranges in Excel, the previous method won’t work here. Here is what you need to do:
- Long-click on the linked cell and let go when you see the cross icon.
- Now, click inside the Formula Bar.
- Select the linked URL as shown in the image.
- Press the Delete key to remove the old URL.
- Now, copy the updated hyperlink from the source.
- Come back to Excel and press Ctrl + V to paste the link.
- Ensure the pasted URL is within double quotes.
- Hit Enter to save the changes you just made.
Editing the Anchor Text of Links in Excel
Another link customization you might need to do is to change the anchor or display the text of a link or hyperlink. Here are the two methods you need to know:
Altering Anchor Texts for Hyperlinks Created With Link To
- Open the Excel workbook in which you have hyperlinks that you want to edit.
- Click on the cell that contains the hyperlink you want to modify.
- Right-click on the hyperlinked cell.
- This action will open a context menu.
- In the context menu, select Edit Hyperlink. This option is usually near the bottom of the menu.
- Locate the Text to display field.
- Modify the content with an updated anchor text.
- Once you are satisfied with your changes, click the OK button in the Edit Hyperlink dialog box.
Changing Anchor Texts for URLs Created With the HYPERLINK Function
Editing the anchor text of a cell linked to a website, worksheet, or workbook is tricky if the hyperlinking was created with the HYPERLINK formula of Excel. Here’s how you can accomplish this feat:
- Long-click the cell containing a hyperlink that needs editing.
- When the icon changes to a cross from the hand palm, let go of the click.
- Now, click on the Formula Bar of the cell.
- You should then see the components of the hyperlinked cell.
- There are mostly two components as mentioned below:
- A hyperlink to a website URL or Excel file on the PC within double quotes
- A cell reference as a display text or a plain text as an anchor text within double quotes
- So, you need to select the referenced cell address or the plain text within double quotes.
- Replace the selected content with the new cell reference or plain text to use as an updated anchor text.
- Press Enter to save the changes.
📒Read More: Check out this post on How to Extract the URL from a Hyperlink in Microsoft Excel!
Editing the Graphics of a Linked URL in Excel
Suppose, you used Text Boxes or Shapes in place of anchor text or both to increase the visibility of your hyperlinks in Excel.
Now, you’ve decided to change the destination of the object or the object itself. Here’s how you can proceed:
- Right-click on the image or object or the text box linked to a URL or workbook.
- Click on the Edit Link option on the context menu that shows up.
- Go to the Address field of the Edit Hyperlink dialog.
- Change the hyperlink or workbook source mentioned in the Address field.
- Click OK to save the changes you just made.
Do you need to change the linked object or button but keep the destination? Unfortunately, there aren’t any shortcut to this like changing the object in its original cell.
You need to create a new Text Box or Shape, format it, and then add the hyperlink from the old object or button to the new one.
However, you can easily edit any text available in those buttons or objects. Here’s how:
- Right-click the object to activate it.
- Now, double-click on the text to select the whole text.
- As soon as you do this, the text formatting box will appear on the top.
- Now, you can change the typeface, font color, text size, font alignment, and so on.
Editing the Look of Hyperlinked Texts in Excel
You can also edit the links in Excel to make them more visible and beautiful especially when sending a report to a non-technical audience. Here are the methods you can follow:
Changing Appearance of the Cell and Text
The Cell Styles tool enables you to customize the view of the cell and text of a hyperlink. You can simply select one cell or a range of cells. Then, click the Cell Styles extension icon to find customization options as mentioned below:
- Data and Model
- Themed Cell Styles
You can go to New Cell Styles to create a unique cell and text formatting as well.
Editing the Text
Find below the quick steps to edit the appearance of the anchor or display text for a hyperlinked cell or cell range in Excel:
- Select one or many cells on your worksheet.
- Press Ctrl + 1 on your keyboard to bring up the Format Cells dialog.
- Go to the Font tab.
- Now, you can easily change the following properties of the anchor text:
- Font
- Font style
- Size
- Effects
- Color
- Once you’re done with text formatting, click OK.
Editing Worksheet and Workbook Links in Excel
Like website URLs, you can also edit the hyperlinked addresses of worksheet and workbooks in Excel. In comparison to workbooks, editing worksheet reference is easier.
For workbooks, you need to carefully enter the complete location of the Excel file. Contrarily, you can change worksheet references visually using the Edit Hyperlink tool. Find below the steps you can try:
- Select the cell that contains a link referrencing to another worksheet in the same workbook.
- Press Ctrl + K to open the Edit Hyperlink dialog.
- There, you should see a tree of worksheets in the workbook.
- Select a different one from the tree to update the worksheet redirecting link.
- Click OK to update.
To edit a workbook refernece, you can do the following:
- Select the cell and bring up the Edit Hyperlink dialog by pressing Ctrl + K.
- Now, you can click the Look in drop-down and navigate to the folder where the target workbook is located.
- Click on the file and click OK to update the workbook hyperlink.
- Alternatively, you can enter a complete directory address of the workbook in the following format into the Address field:
c:/users/ctos/downloads/vgsales.csv
or
d:/excelworkbooks/vgsales.csv
- Again, click OK to save the changes made.
Edit Links Using Excel VBA
If you need to automate the link editing tasks in Excel, Excel VBA can help. You can write or use a few lines of codes to automate the whole thing and change the destination address or anchor text in a jiffy.
Find below a code to edit the destination and anchor text of a hyperlink by implementing minor code changes. Here are the steps:
- Open the Excel VBA Editor from Developer > Visual Basic.
- Now, click the the Insert button on the Excel VBA Editor toolbar.
- Choose Module and paste the following script into it:
Sub EditHyperlinkInCell()
Dim ws As Worksheet
Dim cell As Range
Dim newURL As String
Dim newText As String
' Set the target worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
' Set the target cell (A2)
Set cell = ws.Range("A2")
' Define the new URL and anchor text
newURL = "https://www.newurl.com" ' Replace with your desired URL
newText = "Anchor Text" ' Replace with your desired anchor text
' Check if the cell contains a hyperlink
If cell.Hyperlinks.Count > 0 Then
' Edit the existing hyperlink in the cell
cell.Hyperlinks(1).Address = newURL
cell.Hyperlinks(1).TextToDisplay = newText
Else
' If there is no existing hyperlink, create a new one
cell.Hyperlinks.Add _
Anchor:=cell, _
Address:=newURL, _
TextToDisplay:=newText
End If
End Sub
- Click Save and close the Excel VBA Editor.
Now, press Alt + F8 keys to open the Macro dialog box. There, select the EditHyperlinkInCell macro and click Run to change the hyperlink URL, anchor text, or the both.
Here’s how you can modify the script:
- Change
"Sheet1"
to actual worksheet name - Modify cell reference
A2
in code elementws.Range("A2")
to select the target cell - Enter the new hyperlink or workbook address in the
newURL
field within double quotes - Similarly, enter the new display text in the
newText
field within double quotes
The above VBA script will only work if you’ve inserted the hyperlink using the Link tool on the Insert tab.
If the target cell has a link created using the HYPERLINK function, use this script instead:
Sub EditHyperlinkInCellB2()
Dim ws As Worksheet
Dim cell As Range
Dim formulaText As String
Dim newURL As String
Dim newText As String
' Set the target worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
' Set the target cell (C2)
Set cell = ws.Range("C2")
' Define the new URL and anchor text
newURL = "https://www.newurl.com" ' Replace with your desired URL
newText = "Anchor Text" ' Replace with your desired anchor text
' Check if the cell contains a HYPERLINK formula
If InStr(1, cell.Formula, "=HYPERLINK(", vbTextCompare) > 0 Then
' Extract the formula text
formulaText = cell.Formula
' Modify the URL and anchor text within the formula
formulaText = Replace(formulaText, Chr(34) & "https://www.howtoexcel.org/change-table-style" & Chr(34), Chr(34) & newURL & Chr(34))
formulaText = Replace(formulaText, Chr(34) & "Visit Now" & Chr(34), Chr(34) & newText & Chr(34))
' Set the modified formula in the cell
cell.Formula = formulaText
End If
End Sub
Edit Hyperlinks in Excel Using Office Scripts
Find below how can you automate the hyperlink editing in Excel for the web or Excel for Microsoft 365 desktop app using Office Scripts. This method works on links created using the Link tool.
- Go to the Automate tab and click the New Script command.
- Now, copy and paste the following Office Scripts code inside the Code Editor panel.
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
// Apply hyperlink to range A2 on selectedSheet}
selectedSheet.getRange("A2").setHyperlink({textToDisplay: "Anchor", address: "https://www.newurl.com/updated1/"});
}
- Click the Save script button.
- Click Run to execute.
Here’s how to customize the script:
- Change all the instances of
A2
with the cell reference of the target cell for which you want to edit the anchor text and destination address. - Enter the new anchor text within double quotes into the
textToDisplay
field. - Similarly, enter the new link into the
address
field.
Find below another Office Scripts code that enables you to automate link editing for those cells that have the HYPERLINK function:
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
// Set range C2 on selectedSheet
selectedSheet.getRange("C2").setFormulaLocal("=HYPERLINK(\"https://www.newurl.com/update1\",\"Anchor Text\")");
}
Note: Office Scripts-based automation is only available if you got Microosft 365 Businsess Standard or better subscription.
Conclusions
Mastering the art of editing links in Excel is a valuable skill that empowers you to take control of your data, streamline your work, and maintain the integrity of your spreadsheets.
Whether you’re fine-tuning hyperlinks to web resources, or optimizing links to external workbooks, understanding the ins and outs of link editing can save you time, prevent errors, and enhance your overall productivity.
The above methods are suited to different situations of link editing in Excel. Pick a method that suits your scenario. If you know any popular method that I missed or just want to give feedback, don’t forget to comment below.
0 Comments