Hi folks, new to these forums, hoping that someone can help me out.
I am trying to create a spreadsheet that stores readings from a bar code scanner along with the date and time of the scan. I have managed to get it working on a simple level but need to take it on to the next level.
Currently, the cursor starts in cell A1, the barcode is scanned, the date and time are entered automatically into cell A2 and the cursor moves to cell B2 awaiting the next barcode scan.
This is my current code entered in the 'view code' area of worksheet1.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Intersect(Target, Range("A1:A10")) Is Nothing Then Exit Sub
ActiveCell.Offset(-1, 1).Select
If Target.Cells.Count = 1 And Target.Column = 1 Then
Target.Offset(0, 1) = Now
End If
ActiveCell.Offset(1, -1).Select
End Sub
What I would like to happen is that the cursor constantly sits in cell A1 on worksheet1, the barcode is scanned and the relevant data be placed in cell A1 and A2 on worksheet2. The next scan causes the new data to be placed in cell B1 and B2 on worksheet 2. No data needs to be stored on worksheet1, I'd like it cleared after each scan and the cursor to remain in cell A1. Worksheet1 will be used solely as a 'data entry screen', locked down appropriately so users can't get in too much of a mess.
I'm new to Excel coding (or any form thereof!) and am a little stuck as to how to go about this.
Any pointers would be much appreciated.
thanks.
I am trying to create a spreadsheet that stores readings from a bar code scanner along with the date and time of the scan. I have managed to get it working on a simple level but need to take it on to the next level.
Currently, the cursor starts in cell A1, the barcode is scanned, the date and time are entered automatically into cell A2 and the cursor moves to cell B2 awaiting the next barcode scan.
This is my current code entered in the 'view code' area of worksheet1.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Intersect(Target, Range("A1:A10")) Is Nothing Then Exit Sub
ActiveCell.Offset(-1, 1).Select
If Target.Cells.Count = 1 And Target.Column = 1 Then
Target.Offset(0, 1) = Now
End If
ActiveCell.Offset(1, -1).Select
End Sub
What I would like to happen is that the cursor constantly sits in cell A1 on worksheet1, the barcode is scanned and the relevant data be placed in cell A1 and A2 on worksheet2. The next scan causes the new data to be placed in cell B1 and B2 on worksheet 2. No data needs to be stored on worksheet1, I'd like it cleared after each scan and the cursor to remain in cell A1. Worksheet1 will be used solely as a 'data entry screen', locked down appropriately so users can't get in too much of a mess.
I'm new to Excel coding (or any form thereof!) and am a little stuck as to how to go about this.
Any pointers would be much appreciated.
thanks.