how can i display number of hour worked by an user please help me out

tiger123

New Member
Joined
Jun 24, 2014
Messages
37
i have taken an label 6 for display number of hours taken by an user


taken from the current login time to logout time

and there is break time 1:30 to 2:15 pm

how can i write an vba code

this is my login vba code

Code:
Private Sub cmdbt1_Click()Dim irow As Long
Dim ws As Worksheet




Dim info
info = IsWorkBookopen("\\bms\Service log request\login details\workstation.xlsx")




'we open the workbook if it is closed
If info = False Then
Workbooks.Open ("\\bms\Service log request\login details\workstation.xlsx")
End If


 Set ws = Worksheets("Login Time")


'Find first empty row in database
 irow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
 SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1






'Check for a Name number
If Trim(Me.TextBox1.Value) = "" Then
Me.lbl2.SetFocus
End If


'Copy the data to the database
ws.Cells(irow, 1).Value = Me.lbl2.Object
ws.Cells(irow, 3).Value = Me.lbl4.Object
ws.Cells(irow, 4).Value = Me.lbl6.Object
ws.Cells(irow, 2).Value = Me.Label2.Object
ws.Cells(irow, 5).Value = Me.TextBox3.Value
ws.Cells(irow, 6).Value = Me.TextBox1.Value
ws.Cells(irow, 7).Value = Me.TextBox2.Value
'Me.lbl2.Name = ""
'Me.lbl4.Name = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""


Me.TextBox1.SetFocus


'Application.DisplayAlerts = False
Workbooks("workstation.xlsx").Save
Workbooks("workstation.xlsx").Close
Application.DisplayAlerts = True






MsgBox "welcome to bms"
End Sub
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,222,437
Messages
6,166,023
Members
452,008
Latest member
Customlogoflipflops

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