Please edit this macro for me...thanks everyone!

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
(y)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-com:eek:ffice:eek:ffice" /><o:p></o:p>
' Updates the clock that's visible<o:p></o:p>
Dim Clock As Chart<o:p></o:p>
Set Clock = ThisWorkbook.Sheets("Sheet1").ChartObjects("ClockChart").Chart<o:p></o:p>
<o:p></o:p>
If Clock.Parent.Visible Then<o:p></o:p>
' ANALOG CLOCK<o:p></o:p>
Const PI As Double = 3.14159265358979<o:p></o:p>
Dim CurrentSeries As Series<o:p></o:p>
Dim s As Series<o:p></o:p>
Dim x(1 To 2) As Variant<o:p></o:p>
Dim v(1 To 2) As Variant<o:p></o:p>
<o:p></o:p>
' Hour hand<o:p></o:p>
Set CurrentSeries = Clock.SeriesCollection("HourHand")<o:p></o:p>
x(1) = 0<o:p></o:p>
x(2) = 0.5 * Sin((Hour(Time) + (Minute(Time) / 60)) * (2 * PI / 12))<o:p></o:p>
v(1) = 0<o:p></o:p>
v(2) = 0.5 * Cos((Hour(Time) + (Minute(Time) / 60)) * (2 * PI / 12))<o:p></o:p>
CurrentSeries.XValues = x<o:p></o:p>
CurrentSeries.Values = v<o:p></o:p>
<o:p></o:p>
' Minute hand<o:p></o:p>
Set CurrentSeries = Clock.SeriesCollection("MinuteHand")<o:p></o:p>
x(1) = 0<o:p></o:p>
x(2) = 0.8 * Sin((Minute(Time) + (Second(Time) / 60)) * (2 * PI / 60))<o:p></o:p>
v(1) = 0<o:p></o:p>
v(2) = 0.8 * Cos((Minute(Time) + (Second(Time) / 60)) * (2 * PI / 60))<o:p></o:p>
CurrentSeries.XValues = x<o:p></o:p>
CurrentSeries.Values = v<o:p></o:p>
<o:p></o:p>
' Second hand<o:p></o:p>
Set CurrentSeries = Clock.SeriesCollection("SecondHand")<o:p></o:p>
x(1) = 0<o:p></o:p>
x(2) = 0.85 * Sin(Second(Time) * (2 * PI / 60))<o:p></o:p>
v(1) = 0<o:p></o:p>
v(2) = 0.85 * Cos(Second(Time) * (2 * PI / 60))<o:p></o:p>
CurrentSeries.XValues = x<o:p></o:p>
CurrentSeries.Values = v<o:p></o:p>
Else<o:p></o:p>
' DIGITAL CLOCK<o:p></o:p>
ThisWorkbook.Sheets("Sheet1").Range("DigitalClock").Value = CDbl(Time)<o:p></o:p>
End If<o:p></o:p>
<o:p></o:p>
' Set up the next event one second from now<o:p></o:p>
NextTick = Now + TimeValue("00:00:01")<o:p></o:p>
Application.OnTime NextTick, "Updateclok"<o:p></o:p>
<o:p></o:p>
 
You're right i tried running this in excel sheet1. In sheet1 i have merged cell A1:D3 and named it DigitalClock.

I'm poor in this things..please give me the intruction as what i should do thank you.

THanks for your help!!!
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
A very special thanks to Greg Truby!!!

This is great..i didnt know that this is that easy... i was not doing it correctly...thanks again!!:)
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,845
Members
449,471
Latest member
lachbee

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