Share via

Excel Visual Basic

Anonymous
2022-05-14T04:48:19+00:00

Hello. Was wondering if you could help me with a workbook I'm trying to create. The purpose is to track employees with numbers; on the first sheet (Form) someone will scan their number, it will then get stored on a second sheet with time stamp. The next time the number is scanned it finds the previous entry then adds another time stamp in the column next to the first.

Like this coding but I need the "barcode" entered on one sheet with the data on another

Sub inout()

Dim barcode As String

Dim rng As Range

Dim rownumber As Long

barcode = Worksheets("Sheet1").Cells(2, 2)

Set rng = Sheet1.Columns("a:a").Find(What:=barcode, \_ 

LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, \_ 

SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) 

If rng Is Nothing Then 

    ActiveSheet.Columns("a:a").Find("").Select 

    ActiveCell.Value = barcode 

    ActiveCell.Offset(0, 1).Select 

    ActiveCell.Value = Date & "  " & Time 

    ActiveCell.NumberFormat = "m/d/yyyy h:mm AM/PM" 

    Worksheets("Sheet1").Cells(2, 2) = "" 

Else 

    rownumber = rng.Row 

    Worksheets("Sheet1").Cells(rownumber, 1).Select 

    ActiveCell.Offset(0, 2).Select 

    ActiveCell.Value = Date & "  " & Time 

    ActiveCell.NumberFormat = "m/d/yyyy h:mm AM/PM" 

    Worksheets("Sheet1").Cells(2, 2) = "" 

End If 

End Sub

Please help

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

7 answers

Sort by: Most helpful
  1. Anonymous
    2022-05-14T07:24:26+00:00

    Once the same number is scanned in sheet1 sheet2 would look like this

    0 comments No comments
  2. Anonymous
    2022-05-14T07:23:17+00:00

    This is sheet2 Data. Once scanned on sheet1 sheet2 would look like this.

    0 comments No comments
  3. Anonymous
    2022-05-14T07:22:09+00:00

    This is sheet1 Form,

    0 comments No comments
  4. Anonymous
    2022-05-14T07:10:09+00:00

    Sheet1 which I call Form, in cell D16 a barcode is scanned. Im trying to get that barcode to go to sheet2 which I call Data in cell A3 with a timestamp in B3. Once it goes to sheet2 D16 should go back blank. When the same barcode is scanned again into sheet1 D16 I want the data to find it previous log then just add another time stamp two cells to the right (so in this case C3). When barcode is scanned is should look for the next empty cell in A column unless it was previously scanned once.

    0 comments No comments
  5. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2022-05-14T06:55:40+00:00

    Your scanner writes a barcode in which sheet and in which cell?

    The barcode should be written into column A in which sheet?

    Please answer this questions clearly, no extra explanations needed.

    Andreas.

    0 comments No comments