Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi Guys, I have the code to set the movement of cell and it does the job but the view pane not moving to the selected cell pane. Please advise how to make the view pane moves as well.
My example is here after I entered value in cell AL6, it will move to cell H7 but my view pane remains there.
My example is here after I entered value in cell AL6, it will move to cell H7 but my view pane remains there.
VBA Code:
Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
'Set Cell Movement within The Range
Dim rngR As Range
Dim lastRowR As Long, lastColR As Long
Set rngR = Range("A1").CurrentRegion
lastRowR = Cells(Rows.Count, "A").End(xlUp).Row
lastColR = Cells(1, Columns.Count).End(xlToLeft).Column
If rngR.Rows.Count > 2 Then
Set rngR = Intersect(Target, rngR.Offset(1, 0).Resize(rngR.Rows.Count - 1, rngR.Columns.Count))
Else
Set rngR = Nothing
End If
If Not rngR Is Nothing Then
If Target.Column = 1 And Not (IsEmpty(Target)) Then
Target.Offset(, 7).Select
ElseIf Target.Column = lastColR And Target.Row = lastRowR Then
Target.Offset(, -30).Select
'Application.Goto Target.Offset(, -30)
ElseIf Target.Column = lastColR Then
Target.Offset(1, -30).Select
ElseIf Target.Column = 1 And (IsEmpty(Target)) Then
Target.Cells.Select
Else
Target.Offset(, 1).Select
End If
End If
End Sub