Scan Attendance

Stewart11715

New Member
Joined
Nov 12, 2013
Messages
5
Hello. I would like to change the vba code when I scan an id it will post the student's id one column and the date if possible into the next column.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
' hiker95, 05/27/2013
' Scan barcode to excel with date & time stamp in & out.
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
If Target = "" Then Exit Sub
Dim lr As Long, lc As Long, nc As Long, fr As Long, n As Long, nr As Long
With Application
.EnableEvents = False
.ScreenUpdating = False
n = Application.CountIf(Columns(4), Range("A1"))
If n = 0 Then
nr = Range("D" & Rows.Count).End(xlUp).Offset(1).Row
Range("D" & nr) = Range("A1")
Range("A1").ClearContents
Cells(nr, 8) = Format(Now, "mmm dd,yyyy h:mm AM/PM")
Columns(8).AutoFit
Cells(nr, 1).Resize(, 3) = "???"
Cells(nr, 5).Resize(, 3) = "???"
ElseIf n > 0 Then
fr = 0
On Error Resume Next
fr = Application.Match(Range("A1"), Columns(4), 0)
On Error GoTo 0
lc = Cells(fr, Columns.Count).End(xlToLeft).Column
If lc < 8 Then
Cells(fr, 8) = Format(Now, "mmm dd,yyyy h:mm AM/PM")
Columns(8).AutoFit
ElseIf lc > 7 Then
Cells(fr, lc + 1) = Format(Now, "mmm dd,yyyy h:mm AM/PM")
Columns(lc + 1).AutoFit
End If
End If
With Range("A1")
.ClearContents
.Select
End With
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
 

Attachments

  • Screenshot 2023-10-19 000741.jpg
    Screenshot 2023-10-19 000741.jpg
    188.6 KB · Views: 11

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
This vba code was from a mrexcel post from 2013 that I’m trying to make work for my wife. If you need the source file let me know. Thanks
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,974
Members
449,095
Latest member
Mr Hughes

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