The2ndQuest
New Member
- Joined
- Nov 2, 2024
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
- MacOS
What I'm trying to do is tell a cell to move the cursor to a specific cell after data has been entered. This is basically so that I can use a barcode scanner to scan two barcodes off a box into their respective columns, then go to the next row and repeat the process and avoid having to use the keyboard or mouse between barcodes/boxes. The scanner already automatically hits enter after scanning the barcode. And I do not want to alter any universal settings for Excel cursor movement.
Now, I've managed to figure out how to do some macros in the past via a button or object, but never something auto-running looking at cells. But I've pieced together some idea of the direction to go with two operations. What I want to happen for the first one is if data is entered into C12, then the cursor moves to E12. And the second one is if data is entered into E12, then the cursor moves to F12. And then I can just swap out the cell addresses for the next 12+ rows (probably a way to iterate that in code, but figured I'd just keep it simple and go one by one since there's only a dozen or so rows, so problems can be focused on the more complex cursor code).
What I've pieced together form different google searches was to add this to the sheet in VB (this is just for the E12 to F12 cursor movement, but I can probably figure out how to do the other half once I know how this one works):
The first part supposedly would auto-run this when the sheet is opened, and the latter would monitor for changes to the cells (by checking if they are not blank). But that either doesn't work or I haven't been able to figure out how to place/run it within the sheet (if it's not automatically done so through the VB project screen- I'm unclear on how they interact, or if there is a "compile/add to sheet" process or something I'm not doing).
Any guidance/suggestions are appreciated.
-Billy
Now, I've managed to figure out how to do some macros in the past via a button or object, but never something auto-running looking at cells. But I've pieced together some idea of the direction to go with two operations. What I want to happen for the first one is if data is entered into C12, then the cursor moves to E12. And the second one is if data is entered into E12, then the cursor moves to F12. And then I can just swap out the cell addresses for the next 12+ rows (probably a way to iterate that in code, but figured I'd just keep it simple and go one by one since there's only a dozen or so rows, so problems can be focused on the more complex cursor code).
What I've pieced together form different google searches was to add this to the sheet in VB (this is just for the E12 to F12 cursor movement, but I can probably figure out how to do the other half once I know how this one works):
VBA Code:
Private Sub Worksheet_Activate()
'
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "E12" And Target.Address <> "" Then
Target.Offset(-2, -1).Select
End If
End Sub
The first part supposedly would auto-run this when the sheet is opened, and the latter would monitor for changes to the cells (by checking if they are not blank). But that either doesn't work or I haven't been able to figure out how to place/run it within the sheet (if it's not automatically done so through the VB project screen- I'm unclear on how they interact, or if there is a "compile/add to sheet" process or something I'm not doing).
Any guidance/suggestions are appreciated.
-Billy