How to create an Auto Enter Barcode Scanner in Excel


What Is a Barcode?

Barcode is a machine-readable code. It encodes information with spaces and varying widths of parallel lines. These spaces and lines represent numeric values and characters.

Step 1 – Prepare the Worksheet for Data Entry

Create a data table to place the Barcode Numbers (B5:B14) and to automatically enter Date & Time (C5:C14).

Step by Step Procedures to Make Auto Enter Barcode Scanner in Excel

Read More: How to Use Barcode Scanner in Excel 

Step 2 – Setup the Visual Basic Window

  • Go to the Developer tab and select Visual Basic.

Step by Step Procedures to Make Auto Enter Barcode Scanner in Excel

  • In the Visual Basic window, double-click Sheet1.

Note: The code is entered in the specific sheet. If you type the code in the Module, it will run the whole workbook.
  • Select Worksheet as the object sheet.

  • Select Change as the VBA event.

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

Step 3 – Insert the VBA Macro Code

  • Enter this VBA Macro code in the blank sheet.
Private Sub Worksheet_Change(ByVal Target As Range)

Dim TableRange As Range
Dim DateTimeRange As Range

Set TableRange = Range("B5:B14")

If Intersect(Target, TableRange) Is Nothing Then Exit Sub

Set DateTimeRange = Range("C" & Target.Row)

If DateTimeRange.Value = "" Then
   DateTimeRange.Value = Now

End If

End Sub

Step by Step Procedures to Make Auto Enter Barcode Scanner in Excel

Range (“B5:B14”) and Range (“C”) are changeable according to your dataset. If your Barcode Numbers are in  A4:A10 and outputs in column B, the code will be Range (“A4:A10”) and Range (“B”) respectively.
  • Click Save and close the Visual Basic window.

Read More: Barcode Scanner Entry to Excel Database with Timestamp

Step 4 – Run the Auto Enter Barcode Scanner Code


  • Enter your barcode number in B5.

Step by Step Procedures to Make Auto Enter Barcode Scanner in Excel

  • Press Enter.
  • Date & Time is automatically displayed in C5.

  • Enter each number to get the final output.

Excel Barcode Scanner Auto Enter

Read More: How to Move Barcode Scanner to Next Row in Excel

Download Practice Workbook

Practice here.

Related Articles

<< Go Back to Use Barcode ScannerBarcode in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Sanjida Mehrun Guria
Sanjida Mehrun Guria

Hello! Welcome to my blog. I have completed my Bachelor in Architecture from Ashanullah University of Science & Technology, Dhaka. I am a passionate, goal-oriented person with an immense thirst for knowledge and an attitude to grow continuously. Besides Architectural work, I find it very enthusiastic to work in Excel blogging. Exceldemy is a platform where I have got the opportunity to flourish my skill in Microsoft Excel and therefore, here I will be posting blogs related to... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF