将单元格超链接到同一工作表中的另一个单元格
问题描述:
我想如果在A列下单击x,绿色矩形将移至最右边的1:在A1处单击第一个x会到达(1,P3),A2->(2,P2),A3 ->(3,P2),A4->(4,P3).
I'd like if x is clicked under column A, the green rectangle moves to the 1 to the farthest right: Clicking first x at A1 arrives at (1, P3), A2 -> (2, P2), A3 -> (3, P2), A4 -> (4, P3).
我编写该代码的目的是将A1,A2,A3和A4超链接到相应的PCell.如何获取P列下最右边的1?
I've written the code with an intention to hyperlink A1, A2, A3, and A4 to corresponding PCell. How do I fetch the 1's on the farthest right under the P columns?
还有另一种方法吗?
Sub GoToPCell()
Dim i As Integer, PCell As String
PCell =
For i = 1 To 4
ActiveSheet.Hyperlinks.Add Cells(i, 1), Address:="", SubAddress:="'" & Sheet1.Name & "'!PCell"
Next i
End Sub
答
BigBen先生评论了解决您的问题的主要部分.我刚刚发布了完整的子内容,如下所示.试试...
As Mr. BigBen comment the main part to solve your problem. I have just post full sub as below. Try...
Sub GoToPCell()
Dim i As Integer, PCell As String
For i = 1 To 4
PCell = Cells(i, Columns.Count).End(xlToLeft).Address
ActiveSheet.Hyperlinks.Add Cells(i, 1), Address:="", SubAddress:="'" & Sheet1.Name & "'!" & PCell
Next i
End Sub