Highlighting hyperlinked destination transiently

Hakan K

New Member
Joined
Apr 15, 2023
Messages
3
Office Version
  1. 2016
Platform
  1. MacOS
Hello, I am relatively new to the VB & to the forum. I am also trying to use the VB to highlight the destination cell transiently after hyperlinking from another cell & revert back to the original fill color later on. I have seen some previous posts about this & was wondering whether this is doable. I am using Mac Platform Excel 2016 (v16.16.27)

Thank you,
Hakan K
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You can achieve this by using VBA code to change the fill color of the destination cell after hyperlinking, and then revert back to the original fill color after a certain amount of time. Here's a step-by-step guide:
  1. Press Alt + F11 to open the VBA editor (on a Mac, press Option + F11).
  2. In the "Project Explorer" pane on the left, double-click on the sheet where the hyperlink is located.
  3. Copy and paste the following code into the code window:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim destinationCell As Range
Dim originalColor As Long
Dim delaySeconds As Long

' Set the delay time (in seconds) before reverting the cell color back
delaySeconds = 5 ' You can change this value according to your needs

' Get the destination cell
Set destinationCell = Range(Target.SubAddress)

' Store the original fill color
originalColor = destinationCell.Interior.Color

' Change the fill color of the destination cell
destinationCell.Interior.Color = RGB(255, 255, 0) ' Yellow color

' Wait for the specified delay time
Application.Wait (Now + TimeValue("00:00:" & CStr(delaySeconds)))

' Revert the fill color of the destination cell back to the original color
destinationCell.Interior.Color = originalColor
End Sub


  1. Modify the delaySeconds variable value according to your preference. This value sets the time in seconds before the cell reverts back to its original color.
  2. Close the VBA editor and return to your Excel workbook.
Now, when you click a hyperlink in the worksheet, the destination cell will be highlighted temporarily before reverting back to its original fill color. Note that this code will work for hyperlinks within the same worksheet.

Keep in mind that Excel 2016 for Mac has some limitations in VBA support compared to the Windows version, but the provided code should work without issues on your platform.
 
Upvote 0
You can achieve this by using VBA code to change the fill color of the destination cell after hyperlinking, and then revert back to the original fill color after a certain amount of time. Here's a step-by-step guide:
  1. Press Alt + F11 to open the VBA editor (on a Mac, press Option + F11).
  2. In the "Project Explorer" pane on the left, double-click on the sheet where the hyperlink is located.
  3. Copy and paste the following code into the code window:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim destinationCell As Range
Dim originalColor As Long
Dim delaySeconds As Long

' Set the delay time (in seconds) before reverting the cell color back
delaySeconds = 5 ' You can change this value according to your needs

' Get the destination cell
Set destinationCell = Range(Target.SubAddress)

' Store the original fill color
originalColor = destinationCell.Interior.Color

' Change the fill color of the destination cell
destinationCell.Interior.Color = RGB(255, 255, 0) ' Yellow color

' Wait for the specified delay time
Application.Wait (Now + TimeValue("00:00:" & CStr(delaySeconds)))

' Revert the fill color of the destination cell back to the original color
destinationCell.Interior.Color = originalColor
End Sub


  1. Modify the delaySeconds variable value according to your preference. This value sets the time in seconds before the cell reverts back to its original color.
  2. Close the VBA editor and return to your Excel workbook.
Now, when you click a hyperlink in the worksheet, the destination cell will be highlighted temporarily before reverting back to its original fill color. Note that this code will work for hyperlinks within the same worksheet.

Keep in mind that Excel 2016 for Mac has some limitations in VBA support compared to the Windows version, but the provided code should work without issues on your platform.
Thank you so much, this works really nice. I do appreciate it!
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,952
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top