JoeMoe
02-08-2009, 07:50 AM
I'm trying to automate the process of creating hyperlinks between two specifics cells within a workbook.
The goal is to be able to use a userform with two refedit boxes, select the two cells that I want to cross-reference, and then have Excel do the work.
I have come up with the following (with RefEdit 1 and RefEdit 2 being on a userform; CrossReference is the userform):
Private Sub CommandButton1_Click()
Dim refRange1 As Range
Set refRange1 = Range(RefEdit1)
Dim refRange2 As Range
Set refRange2 = Range(RefEdit2)
refRange1.Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=RefEdit2.Value
refRange2.Activate
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=RefEdit1.Value
CrossReference.Hide
End Sub
The issue is that the above code only works within the same sheet and I really need the code to work between different sheets. Any help would be appreciated.
Thanks!
The goal is to be able to use a userform with two refedit boxes, select the two cells that I want to cross-reference, and then have Excel do the work.
I have come up with the following (with RefEdit 1 and RefEdit 2 being on a userform; CrossReference is the userform):
Private Sub CommandButton1_Click()
Dim refRange1 As Range
Set refRange1 = Range(RefEdit1)
Dim refRange2 As Range
Set refRange2 = Range(RefEdit2)
refRange1.Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=RefEdit2.Value
refRange2.Activate
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=RefEdit1.Value
CrossReference.Hide
End Sub
The issue is that the above code only works within the same sheet and I really need the code to work between different sheets. Any help would be appreciated.
Thanks!