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