Home > Back-end >  Excel VBA Copying 18:00 as 0,750000000003
Excel VBA Copying 18:00 as 0,750000000003

Time:05-23

I have two workbooks, one of them is password protected.

Sub WorkTime()
Dim Employee1 As Workbook

Application.ScreenUpdating = False

    Set Employee1 = Workbooks.Open(Filename:="J:\Firm\Time\Employee1.xlsx", Password:="emp")
    MsgBox (Employee1.Sheets(1).Range("$E3:$E3").Value)

Application.ScreenUpdating = True
End Sub

The value in the Employee-Workbook is 18:00 but when I display it in the MsgBox it comes out as 0,75000000000000003. Every other cell which has a formular in it I already tested aswell and they all display their correct value

CodePudding user response:

That's the numeric time value for 18:00.

Apply a time format or use CDate to convert to a true DateTime value. –

  • Related