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

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
268
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
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,674
Office Version
  1. 2013
Platform
  1. Windows
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
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
268
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Hi My Aswer is This,
It works now. Thanks
 

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
268
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
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
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,674
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

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.
 

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
268
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
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. ?
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,674
Office Version
  1. 2013
Platform
  1. Windows
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.
 

Forum statistics

Threads
1,141,001
Messages
5,703,656
Members
421,309
Latest member
ray crad

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
Top