Move to another cell in same row when active cell is filled

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
382
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Please help to see where the errors are if I want to move from B2 to D2 when B2 data is selected from a dropdown list. , so does other rows in B column in dynamic range.

VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
'Move Cursor to Column D after Row B data selected
    Dim b As String, Lr As Long
    If Target.Column = 2 Then
  If Not Intersect(Target, Range("B2:B" & Lr)) Is Nothing Then Exit Sub
   If Target.Count > 1 Then Exit Sub
   Application.EnableEvents = False
    b = Target.Value
   If b <> "" Then
      Range("D" & ActiveCell.Row).Select
   Else
      ActiveCell.Select
   End If
   Application.EnableEvents = True
 End Sub
 
And you said:
There is no error. It just move down to next row.

It does not move down to next row
It moves to column D
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi,
How the code should be if I want the below function applies to the cells in a dynamic range except the header( row 1 ) and the last column.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

'Set Cursor Direction to Right in Dynamic Range
Dim LastColumn As Long, LastRow As Long

LastRow = Range("A2").End(xlDown).Row
LastColumn = Range("A2").CurrentRegion.Columns.Count

If Target.Cells.CountLarge > 4 or Target.Row =1 Then Exit Sub
   If  Range("A2", Cells(LastRow, LastColumn)) Then

     Application.MoveAfterReturnDirection = xlToRight
     Application.MoveAfterReturn = True

End If

End Sub
 
Upvote 0
Hi,
How the code should be if I want the below function applies to the cells in a dynamic range except the header( row 1 ) and the last column.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

'Set Cursor Direction to Right in Dynamic Range
Dim LastColumn As Long, LastRow As Long

LastRow = Range("A2").End(xlDown).Row
LastColumn = Range("A2").CurrentRegion.Columns.Count

If Target.Cells.CountLarge > 4 or Target.Row =1 Then Exit Sub
   If  Range("A2", Cells(LastRow, LastColumn)) Then

     Application.MoveAfterReturnDirection = xlToRight
     Application.MoveAfterReturn = True

End If

End Sub
So I assume your wanting to use this script for some reason.
I thought you said my script did what you wanted.
I do not understand what your script is trying to do.
 
Upvote 0
So I assume your wanting to use this script for some reason.
I thought you said my script did what you wanted.
I do not understand what your script is trying to do.
Hi, This is another code that I need assistance. What I want is that the cursor movement to the right when working inside the dynamic range. Is it possible. ?
 
Upvote 0
Hi, This is another code that I need assistance. What I want is that the cursor movement to the right when working inside the dynamic range. Is it possible. ?
My previous script selects the cell to the right in column D
Now you want the cursor means the arrow icon to move also.
If that is what you want I do not know how to do that.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,598
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top