Cursor control within event change

kschmeer

New Member
Joined
Oct 8, 2014
Messages
11
I have not been able to resolve my problem searching the internet and trying different methods.

My desired action:

On rows 3 – 55, when the cell in column C or D is changed, the next cell when Tab/Enter is pressed is to be in column F of the current row.

My code works if the user presses the Enter key. However if the Tab key is pressed the next active cell is in the row before the current row, column G due to the offset values.

I have tried using activecell, offset, etc. but I have not been able to get this to work correctly for both the Enter and the Tab key.

Any help would be greatly appreciated.


Private Sub Worksheet_Change(ByVal Target As Range)
Dim PaidCells As Range
Dim DepositCells As Range

Set PaidCells = Range("C1:C55")
Set DepositCells = Range("D1:D55")

If ActiveSheet.Name = "Register" Then
'PAID COLUMN: C
If Not Application.Intersect(PaidCells, Range(Target.Address)) Is Nothing Then
ActiveCell.Offset(-1, 3).Select 'Enter key advances a row, offset back that row
'advance 3 columns to column G
End If

'DEPOSIT COLUMN: E
If Not Application.Intersect(DepositCells, Range(Target.Address)) Is Nothing Then
ActiveCell.Offset(-1, 2).Select 'Enter key advances a row, offset back that row
'advance 2 columns to column G
End If
End If

End Sub 'Worksheet_Change
 
Last edited:

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
If you want the active cell to go to column F try changing this:

ActiveCell.Offset(-1, 2).Select

to this:

Cells(Target.Row, "F").Select
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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