我将从Hyperlinking a cell to another cell in the same worksheet获得的解决方案应用于更大的工作表,该工作表中除了P1,P2和P3之外还有其他列。例如,P3之后有许多列,P1,P2和P3中有一些。但是单击x时,即使它们都是空的,它们也都到达了最后一列中的单元格。我只希望x取到P中对应的那个,而忽略其余的列。如何修复代码?
Sub GoToPCell()
Dim i As Integer
Dim PCell As String
For i = 2 To 5
PCell = Cells(i, "FJ").End(xlToLeft).Address
ActiveSheet.Hyperlinks.Add Cells(i, 2), Address:="", SubAddress:="'" & Sheet1.Name & "'!" & PCell
Next i
End Sub