VBA Help: Auto populating specific cells with Times

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
im currently attempting to create a sheet that logs times and i have the following:


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Target.Column = 1 And Target.Row > 1 Then
        Target.Cells.Offset(0, 1) = Date
        Target.Cells.Offset(0, 2) = Time()
        Target.Cells.Offset(0, 4).Select
    End If
    
    If Target.Column = 4 And Target.Row > 1 Then
        Target.Cells.Offset(1, -3).Select
    End If
    Application.EnableEvents = True
    End Sub


Basically:
Cell A2 is scanned with a barcode scanner
Cell B2: Current Date
Cell C3: Current Time
Cell D3: Left Blank until criteria is met (see below)
Cell E3: Username


What im wanting is the End Time to be populated the next time the user is logged a new start time (if that makes sense) and only when the start time + current time is greater than 1 minute


example screen after 1st entry:
3bfbd48a8c.png



if same name is logged again after 1 minute, all his previous blank entries are filled with current time
if same name is logged again under 1 minute the above is skipped


170a48f038.png


appreciate any help
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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