2016-06-07 3 views
-1

내가 원하는 것은 텍스트로 구성된 셀을 클릭하면 뷰가 셀이 링크 된/연결되어있는 곳으로 이동되도록하는 것입니다.동일한 워크 시트의 다른 셀에 하나의 셀 연결 Excel

예를 들어 50 개의 열이 있다고 가정 해 보겠습니다. 48,35 또는 40 열의 오른쪽으로 이동하려면 시간이 많이 걸립니다. 따라서 셀 또는 어쩌면 나를 해당 열로 이동하는 단추를 원합니다.

필자는 검색을 시도했지만 어쩌면 함수의 이름이 다른 것입니다. 어쨌든 누군가가 내게 이런 일이 일어날 수있는 방법이나 정보가있는 곳을 알 수 있기를 바랍니다.

다음 두 그림은 내가 달성하고자하는 것을 설명합니다. After I press this button

The result

+0

언제든지 '추적 우선 순위'버튼을 클릭하고 그려진 선을 더블 클릭하면 두 개의 셀 사이를 이동할 수 있습니다. –

답변

0

그것은 당신이 얘기 정말 링크가 아니라 당신이 버튼이 코드에 영향을 미칠 경우, 그것은 당신의 요구에 포함해야한다 : Cell A1에 포함 된 가정

Sub test_navi() 

    Dim ColNb As Integer 

    ColNb = InputBox("Type the number of the column you want to go to :", "Navigation", "38") 
    If ColNb > 0 Then 
     ActiveSheet.Cells(2, ColNb).Select 
    Else 
    End If 

End Sub 
+0

이것은 좋지만, 어느 위치가 움직일지를 입력 할 필요없이 버튼을 그 위치에 연결하기를 원합니다. 사용자가 버튼을 클릭하고 텍스트 입력없이 정확한 위치로 이동하게하고 싶습니다. –

0

을 열을 이동하려는 숫자는 다음과 같이 사용할 수 있습니다.

col = CLng(Range("A1").Value) 
ActiveWindow.ScrollColumn = col 
0

" A1 셀에 "아이디어, 워크 시트 Worksheet_Change 이벤트는 셀에서 원하는 열 인덱스를 입력 너무

을 사용할 수있다" "(하지만 당신이 원하는대로 세포 일 수있다)하고있다"자동적으로 "선택한 열을 선택

장소 워크 시트 코드 창에서 다음 코드를 코드의

Option Explicit 

Private Sub Worksheet_Change(ByVal Target As Range) 
    Dim val As Long 
    Dim strng As String 
    Dim mixed As Boolean 

    If Target.Address(False, False) = "A1" Then '<~~ just change "A1" with whatever cell address you want to type column index in 
     If IsEmpty(Target) Then Exit Sub 

     Application.EnableEvents = False 

     GetValAndNumber Target, val, strng, mixed '"interpret" the value input in cell A1 

     On Error Resume Next 'prevent possible invalid inputs could error subsequent 'Range' methods calls 
     If mixed Then 
      Range(Target.Value).Select 
     Else 
      Cells(1, Target.Value).Select 
     End If 
     On Error GoTo 0 

     Application.EnableEvents = True 
    End If 
End Sub 


Sub GetValAndNumber(cell As Range, valLng As Long, strng As String, mixed As Boolean) 
    Dim valStrng As String, char As String 
    Dim i As Long 

    With cell 
     For i = 1 To Len(.Value2) 
      char = Mid(.Value2, i, 1) 
      If char Like "[0-9]" Then 
       valStrng = valStrng & char 
       If strng <> "" Then Exit For 
      Else 
       strng = strng & char 
       If valStrng <> "" Then Exit For 
      End If 
     Next i 
    End With 

    mixed = strng <> "" And valStrng <> "" 
    If strng <> "" Then 
     mixed = valStrng <> "" 
     If mixed Then valLng = CLng(valStrng) 
    Else 
     If valStrng <> "" Then valLng = CLng(valStrng) 
    End If 
End Sub 
0

어쩌면이 두 비트는 - 당신의 세포는 하나의 선례가있는 경우 작동합니다.

Public Sub FindPrecedent() 

    Dim StartCell As Range 
    Set StartCell = ActiveCell 
    StartCell.ShowPrecedents 
    StartCell.NavigateArrow TowardPrecedent:=True, ArrowNumber:=1, LinkNumber:=1 
    StartCell.Parent.ClearArrows 

End Sub 

Public Sub FindDependent() 

    Dim StartCell As Range 
    Set StartCell = ActiveCell 
    StartCell.ShowDependents 
    StartCell.NavigateArrow TowardPrecedent:=False, ArrowNumber:=1, LinkNumber:=1 
    StartCell.Parent.ClearArrows 

End Sub 
관련 문제