Click link changes the value of another cell

dagarcia_mwc

New Member
Joined
Jun 10, 2021
Messages
2
Office Version
  1. 2010
Platform
  1. Windows
Need help, is there an excel formula for my problem

A1 is a hyperlink of a url
if I click the link B1 should be marked as 1

A2 is a hyperlink of a url
if I click the link B2 should be marked as 2
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Not a formula, but a macro should work. Right click on the sheet tab on the bottom and select View Code. Paste the following code into that window:

VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

    If Target.Address = Range("A1").Value Then Range("B1") = 1
    If Target.Address = Range("A2").Value Then Range("B2") = 2

End Sub

This should work if it's a regular hyperlink, and not the HYPERLINK function.
 
Upvote 0
Not a formula, but a macro should work. Right click on the sheet tab on the bottom and select View Code. Paste the following code into that window:

VBA Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

    If Target.Address = Range("A1").Value Then Range("B1") = 1
    If Target.Address = Range("A2").Value Then Range("B2") = 2

End Sub

This should work if it's a regular hyperlink, and not the HYPERLINK function.
Hello, thank you for this. :)

Is there a different marco for a link of sharepoint files?

Looking forward to your help again :)
 
Upvote 0
I can't say anything about sharepoint files, but the above macro should work for links to files on local drives.
 
Upvote 0

Forum statistics

Threads
1,214,667
Messages
6,120,818
Members
448,990
Latest member
rohitsomani

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