VBAについて教えてください。 ユーザーフォーム上で登録ボタンがあるのですが、処理後、入力された箇所へ (Shift + Space みたいに)飛びたいのですが教えてください。 Private Sub 新規登録_Click() Dim targetcell As Range Dim r As Long Dim ck As Boolean With Worksheets("データ") .Select .Unprotect '未入力の項目がないかチェック If TextBox1.Value = "" Then MsgBox "通称名は必須入力です!" Exit Sub '処理を強制終了 End If If .Cells(2, 1).Value = "" Then set_rtn (2) Else For r = 2 To .Cells(Rows.Count, 1).End(xlUp).Row If .Cells(r, 1).Value = "" Then set_rtn (r) ck = True Exit For End If Next r If ck = False Then set_rtn (.Cells(Rows.Count, 1).End(xlUp).Row + 1) End If End If .Protect End With MsgBox "追加しました" Unload UserForm1 ActiveWorkbook.Save End Sub Sub set_rtn(r As Long) With Worksheets("データ") If r = 2 Then .Cells(r, 1).Value = 1 Else .Cells(r, 1).Value = .Cells(r - 1, 1).Value + 1 End If .Cells(r, 2).Value = TextBox1.Value .Cells(r, 3).Value = TextBox8.Value .Cells(r, 4).Value = TextBox9.Value .Cells(r, 5).Value = TextBox2.Value .Cells(r, 6).Value = TextBox6.Value .Cells(r, 7).Value = ComboBox1.Value .Cells(r, 8).Value = TextBox12.Value .Cells(r, 10).Value = TextBox10.Value .Cells(r, 11).Value = ComboBox9.Value .Cells(r, 12).Value = TextBox26.Value .Cells(r, 13).Value = ComboBox8.Value .Cells(r, 14).Value = ComboBox7.Value .Cells(r, 17).Value = ComboBox6.Value .Cells(r, 18).Value = TextBox25.Value .Cells(r, 19).Value = ComboBox5.Value .Cells(r, 22).Value = TextBox15.Value .Cells(r, 23).Value = TextBox16.Value .Cells(r, 24).Value = TextBox18.Value .Cells(r, 25).Value = TextBox17.Value .Cells(r, 26).Value = TextBox20.Value .Cells(r, 27).Value = ComboBox2.Value .Cells(r, 28).Value = TextBox24.Value .Cells(r, 29).Value = ComboBox3.Value .Cells(r, 30).Value = ComboBox4.Value .Cells(r, 33).Value = TextBox21.Value .Cells(r, 34).Value = TextBox22.Value End With End Sub
Visual Basic