ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to move to 1st cell in next row after exit a particular cell. (https://www.excelbanter.com/excel-programming/359002-how-move-1st-cell-next-row-after-exit-particular-cell.html)

Wind54Surfer

How to move to 1st cell in next row after exit a particular cell.
 
Hi all, a newbie question

I need to move to say: A6 after exiting M5, (then to A7 after exiting M6 and
so on...)

Is there a way to do this even if nothing was entered in the M5 cell?

Thanks in advance,
Emilio



Norman Jones

How to move to 1st cell in next row after exit a particular cell.
 
Hi Emilio,

Try:
'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.EnableEvents = False
If Target.Column = 13 Then 'Column M
Cells(Target.Row + 1, "A").Select
End If
Application.EnableEvents = True

End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman



"Wind54Surfer" wrote in message
...
Hi all, a newbie question

I need to move to say: A6 after exiting M5, (then to A7 after exiting M6
and
so on...)

Is there a way to do this even if nothing was entered in the M5 cell?

Thanks in advance,
Emilio





Norman Jones

How to move to 1st cell in next row after exit a particular cell.
 
Hi Emilio,

Perhaps, nearer to your requirement, try:

'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.EnableEvents = False
Cells(Target.Row + 1, "A").Select
Application.EnableEvents = True
End Sub
'<<=============

---
Regards,
Norman



Norman Jones

How to move to 1st cell in next row after exit a particular cell.
 
Hi Emilio,

Or, to avoid next row selection if column A is the active column, try:

'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo XIT
Application.EnableEvents = False
If Target.Column 1 Then
Cells(Target.Row + 1, "A").Select
End If

XIT:
Application.EnableEvents = True
End Sub
'<<=============


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Emilio,

Perhaps, nearer to your requirement, try:

'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.EnableEvents = False
Cells(Target.Row + 1, "A").Select
Application.EnableEvents = True
End Sub
'<<=============

---
Regards,
Norman




Wind54Surfer

How to move to 1st cell in next row after exit a particular ce
 
Thanks Norman,

Actually the first answer worked the best.
All I had to do is changed to "14"

Thanks again,
Emilio

"Norman Jones" wrote:

Hi Emilio,

Or, to avoid next row selection if column A is the active column, try:

'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

On Error GoTo XIT
Application.EnableEvents = False
If Target.Column 1 Then
Cells(Target.Row + 1, "A").Select
End If

XIT:
Application.EnableEvents = True
End Sub
'<<=============


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Emilio,

Perhaps, nearer to your requirement, try:

'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Application.EnableEvents = False
Cells(Target.Row + 1, "A").Select
Application.EnableEvents = True
End Sub
'<<=============

---
Regards,
Norman






All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com