pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
The below code works very well but it is design for both ANALOG CLOCK & DIGITAL CLOCK: ANALOG CLOCK is prepared with the help of MS PPT. I just want this macro to be edited for DIGITAL CLOCK only.
Please help...any help will be appriciated:
Sub Updateclok()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
' Updates the clock that's visible<o></o>
Dim Clock As Chart<o></o>
Set Clock = ThisWorkbook.Sheets("Sheet1").ChartObjects("ClockChart").Chart<o></o>
<o></o>
If Clock.Parent.Visible Then<o></o>
' ANALOG CLOCK<o></o>
Const PI As Double = 3.14159265358979<o></o>
Dim CurrentSeries As Series<o></o>
Dim s As Series<o></o>
Dim x(1 To 2) As Variant<o></o>
Dim v(1 To 2) As Variant<o></o>
<o></o>
' Hour hand<o></o>
Set CurrentSeries = Clock.SeriesCollection("HourHand")<o></o>
x(1) = 0<o></o>
x(2) = 0.5 * Sin((Hour(Time) + (Minute(Time) / 60)) * (2 * PI / 12))<o></o>
v(1) = 0<o></o>
v(2) = 0.5 * Cos((Hour(Time) + (Minute(Time) / 60)) * (2 * PI / 12))<o></o>
CurrentSeries.XValues = x<o></o>
CurrentSeries.Values = v<o></o>
<o></o>
' Minute hand<o></o>
Set CurrentSeries = Clock.SeriesCollection("MinuteHand")<o></o>
x(1) = 0<o></o>
x(2) = 0.8 * Sin((Minute(Time) + (Second(Time) / 60)) * (2 * PI / 60))<o></o>
v(1) = 0<o></o>
v(2) = 0.8 * Cos((Minute(Time) + (Second(Time) / 60)) * (2 * PI / 60))<o></o>
CurrentSeries.XValues = x<o></o>
CurrentSeries.Values = v<o></o>
<o></o>
' Second hand<o></o>
Set CurrentSeries = Clock.SeriesCollection("SecondHand")<o></o>
x(1) = 0<o></o>
x(2) = 0.85 * Sin(Second(Time) * (2 * PI / 60))<o></o>
v(1) = 0<o></o>
v(2) = 0.85 * Cos(Second(Time) * (2 * PI / 60))<o></o>
CurrentSeries.XValues = x<o></o>
CurrentSeries.Values = v<o></o>
Else<o></o>
' DIGITAL CLOCK<o></o>
ThisWorkbook.Sheets("Sheet1").Range("DigitalClock").Value = CDbl(Time)<o></o>
End If<o></o>
<o></o>
' Set up the next event one second from now<o></o>
NextTick = Now + TimeValue("00:00:01")<o></o>
Application.OnTime NextTick, "Updateclok"<o></o>
<o></o>
Please help...any help will be appriciated:
Sub Updateclok()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
' Updates the clock that's visible<o></o>
Dim Clock As Chart<o></o>
Set Clock = ThisWorkbook.Sheets("Sheet1").ChartObjects("ClockChart").Chart<o></o>
<o></o>
If Clock.Parent.Visible Then<o></o>
' ANALOG CLOCK<o></o>
Const PI As Double = 3.14159265358979<o></o>
Dim CurrentSeries As Series<o></o>
Dim s As Series<o></o>
Dim x(1 To 2) As Variant<o></o>
Dim v(1 To 2) As Variant<o></o>
<o></o>
' Hour hand<o></o>
Set CurrentSeries = Clock.SeriesCollection("HourHand")<o></o>
x(1) = 0<o></o>
x(2) = 0.5 * Sin((Hour(Time) + (Minute(Time) / 60)) * (2 * PI / 12))<o></o>
v(1) = 0<o></o>
v(2) = 0.5 * Cos((Hour(Time) + (Minute(Time) / 60)) * (2 * PI / 12))<o></o>
CurrentSeries.XValues = x<o></o>
CurrentSeries.Values = v<o></o>
<o></o>
' Minute hand<o></o>
Set CurrentSeries = Clock.SeriesCollection("MinuteHand")<o></o>
x(1) = 0<o></o>
x(2) = 0.8 * Sin((Minute(Time) + (Second(Time) / 60)) * (2 * PI / 60))<o></o>
v(1) = 0<o></o>
v(2) = 0.8 * Cos((Minute(Time) + (Second(Time) / 60)) * (2 * PI / 60))<o></o>
CurrentSeries.XValues = x<o></o>
CurrentSeries.Values = v<o></o>
<o></o>
' Second hand<o></o>
Set CurrentSeries = Clock.SeriesCollection("SecondHand")<o></o>
x(1) = 0<o></o>
x(2) = 0.85 * Sin(Second(Time) * (2 * PI / 60))<o></o>
v(1) = 0<o></o>
v(2) = 0.85 * Cos(Second(Time) * (2 * PI / 60))<o></o>
CurrentSeries.XValues = x<o></o>
CurrentSeries.Values = v<o></o>
Else<o></o>
' DIGITAL CLOCK<o></o>
ThisWorkbook.Sheets("Sheet1").Range("DigitalClock").Value = CDbl(Time)<o></o>
End If<o></o>
<o></o>
' Set up the next event one second from now<o></o>
NextTick = Now + TimeValue("00:00:01")<o></o>
Application.OnTime NextTick, "Updateclok"<o></o>
<o></o>