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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

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