Senin, September 26, 2016

How To Show Clock (Time) In MS Excel Using Macro

To show time in ms excel using macro, first we must start macro appropriate excel version, please read this article before.

And macro code to show time in ms excel is:

Sub Jam()
Set Sh = ThisWorkbook.Sheets(1)
Sh.Calculate

With Sh.Range("A1")
.FormulaR1C1 = "=Now()"
.NumberFormat = "hh:mm:ss AM/PM"
End With

Time = Now + TimeValue("00:00:01")
Application.OnTime Waktu, "Jam"
End Sub

If we want to dismiss AM or PM, change code:
.NumberFormat = "hh:mm:ss AM/PM"
be:
.NumberFormat = "hh:mm:ss"

If we want to add date, change code:
.NumberFormat = "hh:mm:ss AM/PM"
be:
.NumberFormat = "dd-mm-yyyy hh:mm:ss AM/PM"

Source: Thanks a lot to http://www.rumusexcel.com

0 komentar: