Forum Discussion
GOTO a specific cell, based on another cell's data
If, by chance, you want it to return to column A after keying the data in another column, then you could change this part:
If Intersect(Target.Cells(1), Me.Range("A:A")) Is Nothing Then
Exit Sub
End If
to:
With Target
If Intersect(.Cells(1), Me.Range("A:A")) Is Nothing Then
With .Cells(.Cells.Count)
If .Row < Me.Rows.Count Then
Intersect(.Offset(1, 0).EntireRow, Me.Range("A:A")).Select
End If
End With
Exit Sub
End If
End With
After testing the spreadsheet, I decided I would like to have the cursor return to column A as you suggested. The code you provided does that, however, is it possible to have the cursor move to the target column only on the tab key, and back to column A only when I use the enter key. The way it works now, is after I enter data in my target column, whether I tab or enter, the cursor returns to column A. In some cases, I need to enter data in not only my target column, but a few following columns in that same row. I've attached a copy of the spreadsheet so you can see what I'm working with.
- JMB17Mar 02, 2021Bronze Contributor
Thanks for uploading the workbook, that helps quite a bit.
I added some additional procedures that will reassign the Enter key behavior (both the standard enter key and the numeric keypad enter key) to run a procedure when they are pressed that will go to Column A (next row down).
The enter keys will be reassigned when
1) the workbook is opened and Sheet1 is the active sheet.
2) Sheet1 is activated (switching between worksheets).
3) the workbook is activated and Sheet1 is the active sheet (switching between workbooks).
The enter keys normal function should be restored when
1) the workbook is closed.
2) the worksheet is deactivated (switching to another worksheet).
3) the workbook is deactivated (switching to another workbook).
So, when Column D changes, it should go to the specified column and you should be able to continue to tab/arrow across the worksheet or select with the mouse. Then, hit enter and return to column A. This behavior should only apply to Sheet1 and shouldn't affect other worksheets/workbooks.
- Sue_GMar 03, 2021Copper ContributorYou are the best! Thank you so very much...it works like a charm!!!