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: 9

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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