A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
VBA uses TimeSerial instead of Time:
Range("A" & i).Value = Range("A" & i).Value - TimeSerial(1, 0, 0)
(Time returns the current time in VBA)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
In range A1 -A10 i have time value like 6:28:40 and i would like to decrease the hour by 1 to get 5:28:40
I tried the following macro
Sub test()
Dim i As Integer
For i = 1 To 10
Range("A" & i).Value = Range("A" & i).Value - Time(1, 0, 0)
Next i
End Sub
but i get an error type mismatch
thanks
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
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.
Answer accepted by question author
VBA uses TimeSerial instead of Time:
Range("A" & i).Value = Range("A" & i).Value - TimeSerial(1, 0, 0)
(Time returns the current time in VBA)