How to Fix If the Barcode Scanner Is Skipping Lines in Excel

The List of ID and Barcodes dataset shown in the B4:C13 cells contain the ID number and the corresponding Barcode.

barcode scanner not going to next line in excel


Solution 1: Use the TAB and ENTER Keys

Steps:

  • Go to cell C5 and enter the following formula:

="("&B5&")"

Here, the B5 cell refers to the ID which is 123ABC8462.

Using TAB and ENTER Keys

  • Press TAB to move to cell D5.

press the TAB key

  • Enter “OK” to confirm the scanning >> press ENTER to jump to the next line.

press ENTER key

The cursor moves to the next line in cell C6, ready to store the next barcode.

barcode scanner not going to next line in excel

  • Repeat the same procedure for the other cells to obtain the results shown in the image below.

barcode scanner not going to next line in excel fixed with TAB and ENTER keys

Read More: How to Use Barcode Scanner for Inventory in Excel


Solution 2: Automating the TAB and ENTER Keys with VBA Code

Steps:

  • Go to the Developer tab >> click the Visual Basic button.

Automating the TAB and ENTER Keys with VBA Code

Now, this opens the Visual Basic Editor in a new window.

  • Double-Click on the sheet name where you want to insert the VBA code.

Insert code into worksheet

Enter the following formula into the window:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 2 Then
        Target.Offset(0, 1).Select
    ElseIf Target.Column = 3 Then
        Target.Offset(1, -1).Select
    End If
End Sub

VBA code

Code Breakdown:

Here, I will explain the VBA code in the following steps:

  • Use the If Else statement and the Offset property to move from column C to column D and select cell D5.
  • Use the Offset property to jump to the next line in the C6 cell.

Code explanation

  • Go to the C5 cell and enter the following formula:

="("&B5&")"

In the above expression, cell B5 refers to the ID which is 123ABC8462.

entering formula

  • Pressing ENTER moves the cursor to cell D5.

using ENTER key

  • Enter OK and press ENTER to move to the next line, i.e. cell C6.

moving to next line

Apply the same process and your output should look like the screenshot shown below.

barcode scanner not going to next line in excel fixed with VBAfixed with automated TAB and ENTER


Solution 3: Applying VBA code

Steps:

  • Run beginning steps from the previous methods to open the Visual Basic editor and insert the code into the worksheet.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

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

Applying VBA code

Code Breakdown:

Here, I will explain the VBA code shown in the picture below.

  • Use the If Else statement and the Address property to move from column C to column
  • Enter the current time using the Time function
  • Jump to column E and select the E5 cell.
  • Move to the next line in the C6 cell using Range.Select method.

code explanation

  • Go to cell C5  and enter the following formula:

="("&B5&")"

In this equation, the B5 cell refers to the ID which is 123ABC8462.

type in expression

  • Press ENTER to insert the Time in cell D5 and select cell E5.

log time

  • Type in “OK” in the Status column and press the ENTER key to move to cell C6 in the next line.

barcode scanner not going to next line in excel

Repeat the same process for the other cells and the results should look like the image given below.

barcode scanner not going to next line in excel fixed with VBA code

Read More: Creating Barcode Scanner to Track Check in & Check out Time in Excel


How to Add a Barcode to a Cell in Excel

Steps:

  • Download the IDAHC39M font >> install the font on your computer >> restart Microsoft Excel on your computer.
  • Select the B5:B13 range of cells >> press the CTRL + 1 keys to launch the Format Cells dialog box.

How do I add a barcode to a cell in Excel

  • Choose the Text option >> hit the OK button.

Format Cells option

  • Go to cell C5 and enter the following formula into the Formula Bar:

="("&B5&")"

Here, the B5 cell indicates the ID which is 123ABC8462.

entering formula

  • Use the Fill Handle tool to copy the formula into the cells below.

Using Fill Handle

  • Select the C5:C13 range >> choose the IDAHC39M font from the list.

Changing Font

Your results should appear like the picture shown below.

barcode scanner not going to next line in excel fixed with VBA code

Admittedly, I have skipped the detailed process of making Barcodes in Excel. You may explore it if you wish.

Read More: Barcode Scanner Entry to Excel Database with Timestamp


Practice Section

We have provided a Practice section on the right side of each sheet so you can practice.

Practice Section


Download the Practice Workbook

You can download the practice workbook from the link below.


Get FREE Advanced Excel Exercises with Solutions!
Eshrak Kader
Eshrak Kader

Eshrak Kader is a dedicated professional with a BSc. Degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology. He boasts a rich background in Microsoft Office Suite, and over the past year, he has authored over 120 insightful articles for the ExcelDemy. Currently, Eshrak leads a team of 5 in the ExcelDemy Video project and enjoys problem-solving and making videos on Excel. Eshrak’s passion for continuous learning underscores his commitment to excellence in... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo