VBA Question : click cell link to cell ,which is the same value in other sheet

Bambiyu

New Member
Joined
Mar 25, 2022
Messages
1
Office Version
  1. 365
hello~
I get question of Hyperlinks.

there are ref no. in sheet 1 and sheet 2. I create Hyperlink in sheet1, when click one of ref no. in sheet 1,it will get the cell value then link to sheet 2 .cell in the same value.
For example, user click ref no. A00001 sheet1, then link A00001 in sheet2. Its successful to create hyperlink, but when click the link, system shows error' Reference isn't valid'. I have checked the subaddress get value as image. please give advice ? : )

Dim x As Integer
Dim LastRow As Integer
Dim sName As String
LastRow = Cells(Rows.Count, "a").End(xlUp).Row
sName = "Sheet2"
MsgBox LastRow
With ActiveWorkbook.Worksheets("Sheet1")
For x = 1 To LastRow
Cells(x, "a").Activate
.Hyperlinks.Add Anchor:=ActiveCell, Address:="", SubAddress:=" & Sheet2 & " & ActiveCell.Text, TextToDisplay:=ActiveCell.Text
Next x
End With
 

Attachments

  • Hyperlink.PNG
    Hyperlink.PNG
    30.3 KB · Views: 7

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

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