Written by Allen Wyatt (last updated December 24, 2022)
This tip applies to Excel 2000, 2002, and 2003
Jack likes his Excel hyperlinks to show that they have been visited. Unfortunately, when he saves his workbook, they all get reset to unvisited. Jack wonders if there is some way to make the "visited" status of his hyperlinks survive the Save operation.
There is no way to do this that we've been able to discover. The closest we can come is to check the whether a hyperlink is followed or not and then somehow indicate that status with a condition or value that survives a save operation. For instance, consider the following macros:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim wks As Worksheet Dim hl As Hyperlink Application.ScreenUpdating = False For Each wks In ThisWorkbook.Worksheets For Each hl In wks.Hyperlinks If hl.Parent.Interior.ColorIndex = 37 Then hl.Parent.Interior.ColorIndex = xlNone hl.Parent.Style = "Followed Hyperlink" End If Next hl Next wks Application.ScreenUpdating = True End Sub
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink) Target.Parent.Interior.ColorIndex = 37 End Sub
Every time a hyperlink is followed, the second macro is run. It sets the color of the cell containing the hyperlink. Then, as the workbook is saved, the first macro is run. It checks all the cells containing hyperlinks, and if their interior color is the "key" color (color value of 37), then the style of the cell is set to a style named "Followed Hyperlink". This style setting for the cell will survive the save operation; the only thing you need to do is make sure that you've defined the style to appear as you want your followed hyperlinks to appear.
It should be pointed out that these two macros should be added to the ThisWorkbook module of the workbook. To get to it, display the Visual Basic Editor and double-click on the ThisWorkbook module in the Project Explorer. You can then paste the macros into the resulting code window.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7198) applies to Microsoft Excel 2000, 2002, and 2003.
Best-Selling VBA Tutorial for Beginners Take your Excel knowledge to the next level. With a little background in VBA programming, you can go well beyond basic spreadsheets and functions. Use macros to reduce errors, save time, and integrate with other Microsoft applications. Fully updated for the latest version of Office 365. Check out Microsoft 365 Excel VBA Programming For Dummies today!
If you open workbooks in two instances of Excel, you can use drag-and-drop techniques to create hyperlinks from one ...
Discover MoreDoes it bother you when you enter a URL and it becomes "active" as soon as you press Enter? Here's how you can turn off ...
Discover MoreIf you have a whole slew of hyperlinks in a worksheet and you want to get rid of them, it's easier than you think. This ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments