Move to adjacent cell after barcode scan?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
A barcode scan currently moves down to the cell below.

Is it possible to do this with VBA?
A2: Contents of barcode scan is entered here
B2: Scanned time placed here
C2: Cell selected for user input

I know you can change cell direction in options but this affects all spreadsheets.

Appreciate any help
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Put this code in your worksheet code area: - Provided your scanner is set up to do an 'enter' this will do what you want, alternatively just hit enter once the scan is done.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$A$2" Then
   Range("B2").Value = Time()
   Range("C2").Select
End If
Application.EnableEvents = True
End Sub
 
Last edited:
Upvote 0
Put this code in your worksheet code area: - Provided your scanner is set up to do an 'enter' this will do what you want, alternatively just hit enter once the scan is done.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Address = "$A$2" Then
   Range("B2").Value = Time()
   Range("C2").Select
End If
Application.EnableEvents = True
End Sub

Thankyou this works great :)

Though unsure how to modify to work through the whole columns.

Example after C2 data input, it jumps to A3 awaiting next scan.
 
Upvote 0
This will move to the next rows a column when column C is changed. It works for any row.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

If Left(Target.Address, 3) = "$A$" Then
    
   Range("B" & Target.Row).Value = Time()
   Range("C" & Target.Row).Select
ElseIf Left(Target.Address, 3) = "$C$" Then
   Range("A" & Target.Row + 1).Select
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
Perfect thankyou :)

Just one small blip which im unsure can be avoided.

If you clear the cells in these columns It still triggers the change event and places time
 
Upvote 0
This will check to see if more than 1 cell has been selected - if so it wont do anything. You could develop the 'If Target.Cells.Count=1' line to have multiple tests to catch events that you dont want to have the code run for.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Cells.Count = 1 Then
    If Left(Target.Address, 3) = "$A$" Then
        
       Range("B" & Target.Row).Value = Time()
       Range("C" & Target.Row).Select
    ElseIf Left(Target.Address, 3) = "$C$" Then
       Range("A" & Target.Row + 1).Select
    End If
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
Hi,
A barcode scan currently moves down to the cell below.

Is it possible to do this with VBA?
A2: Contents of barcode scan is entered here
B2: Scanned time placed here
C2: Cell selected for user input

I know you can change cell direction in options but this affects all spreadsheets.

Appreciate any help
I know this is an old post...and you may not still be here but I have a barcode question that I have searched for and can not find the answer. I have everything working on my spreadsheet except for the equipment that I scan is in no practical order. so when I scan the barcode it does not search for that equipment in C2-C200. how did you fix that? right now the only way it will work is if I scan all 200 pieces in order as it is in my spreadsheet. I would be interested on your input on this. I have everything else working except the searching the cell for that barcode scan and it adding the information scanned in the cell A2-A200.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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