• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1995
  • Last Modified:

How to create a scanner barcode timesheet in excel


Im working on creating a employee timesheet  in excel. I have a scanner connected my laptop.

What I want to do is scanned their badge that contains their employee number and in another cell name time the time will appear.

does anybody know what formula I can use that the time and date will appear on a cell when I can the badge.
  • 2
3 Solutions
This formula will return the current date/time based on a non-blank entry in the reference cell:


The formula checks to see if the reference cell (A1) contains a value.  If it does, the function NOW() returns the current date and time.  If the reference cell is blank, the formula returns nothing (i.e., remains "blank").

You'll have to format the column/cell to the desired date/time format.
@mark_harris231, that formula gets recalculated every time Excel performs calculations on the worksheet. Every time a badge was scanned, it would update the time in every row to the current time.
The subroutine that follows will update the cell in column B to the current time whenever a cell in column A is changed. Add the routine to the worksheet.
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 1 Then
        Target.Cells(1, 2).Value = Now()
    End If
End Sub

Open in new window

Let me know if you need help adding the code to your worksheet.

Also, if you want to look a column other than "A" then change the value in the If statement to match the column you want (A=1, B=2, etc.).

The code updates the adjacent column (to the right) to the current date/time. If you wanted a different column, change to "2" to indicate how far over from the current cell (which is always "1") it should move.
LENEROAuthor Commented:
thank you

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now