Excel Countdown

Please post any questions regarding the program here.

Moderator: 2020vision

Excel Countdown

Postby inplay » Tue Dec 19, 2006 9:05 pm

Hello all,
I wan't to start a countdown when the Race turn in play
it should take 20 sek then I want to start betting. I have one which
work but not accurate. Now I set the Time to 8 minutes and it needs only 20 sek :roll:
sometimes the countdown run down when the Race is not in Play I want that the time
stay at 20sek when the Race is not in play and it needs 20sek when I say 20sek
Hope somebody can help me. :lol:

Think the Problem is the Worksheet Calculate which is here:

Private Sub Worksheet_Calculate()
Static Status As Variant
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
If [E2].Value = "In Play" Then
GoTo Xit
Else
Status = [E2].Value
datTime = TimeSerial(12, 8, 0)
bolTimer = True
Call Countdown
End If
Xit:
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub


here is the modul but I think this is ok (':arrow:')


Option Explicit
Option Private Module

Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Public datTime As Date, bolTimer As Boolean

Public Sub Countdown()
If bolTimer Then
datTime = datTime - TimeSerial(0, 0, 1)
With Worksheets("Tabelle1").Cells(2, 23)
.NumberFormat = "m:ss"
.Value = datTime
If datTime > CDate("12:00:01") Then
Application.OnTime Time + TimeSerial(0, 0, 1), "Countdown"
Cells(2, 21) = ""
Else
Cells(2, 21) = "OK"
End If

End With
End If
End Sub

Any help appreciated
Andy
sorry for my bad English
User avatar
inplay
 
Posts: 16
Joined: Sun Dec 17, 2006 12:52 pm
Location: Germany

Postby Mitch » Sat Dec 23, 2006 2:56 pm

Are you using this timer so that you know when to start betting, or so that your code knows when to start betting?
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby inplay » Sat Dec 23, 2006 3:43 pm

I use it that the code knows when to start betting
I have a excel sheet that should back only in play
but when the market open all bets are under 2 so my
sheet will back one horse or all horses whith a small Back price
sorry for my bad English
User avatar
inplay
 
Posts: 16
Joined: Sun Dec 17, 2006 12:52 pm
Location: Germany

Postby Mitch » Mon Dec 25, 2006 2:34 am

I would do it a little bit differently to yours.

I've used X1 for the status and Y1 for when the race went in play, but they can obviously be changed to suit your sheet if you decide to use it.


Code: Select all
Private Sub Worksheet_Calculate()

    If Target.Columns.Count <> 16 Then Exit Sub
    Application.EnableEvents = False
   
    If Cells(2, 5) <> "In Play" Then
        Cells(1, 24) = "NO"
        Cells(1, 25) = ""
        Application.EnableEvents = True
        Exit Sub
    End If
   
    If Cells(1, 24) = "NO" Then
        Cells(1, 24) = "WAIT"
        Cells(1, 25) = Cells(2, 5)
    End If
   
    If Cells(2, 5) - Cells(1, 25) >= TimeSerial(0, 0, 20) Then
        Cells(1, 24) = "OK"
    End If
   
    Application.EnableEvents = True
   
End Sub


I've not tested this but it looks ok I think.
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby inplay » Mon Dec 25, 2006 8:04 pm

Hello Mitch :P


I try this the whole time to program.
Unfortunately I am not familiar with VBA and therefore tried it with the countdown.

As I inserted your code, a mistake-news came :shock:

"Option is missing", and the first line was yellow marked now, I have the lines:

If Target.Columns.Count < > 16 Then Exit sub
Application.EnableEvents = False

Deleted.

I hope that this doesn't cause any problems in the program.

Then, a small mistake was in the program You copied cell E2 to X1 which is the “in Play” cell.
But we need the clock in X1 which is in cell C2 :idea:
I had considered the whole time why you copied "in Play."

Unfortunately I could not test it yet because there are no Races today. :(

But I believe it work. 8)


Thank’s for your help

I will report if it works.
sorry for my bad English
User avatar
inplay
 
Posts: 16
Joined: Sun Dec 17, 2006 12:52 pm
Location: Germany

Postby Mitch » Mon Dec 25, 2006 11:54 pm

I didn't recognise that you had used worksheet_calculate and I normally use worksheet_change, so I've changed that in the code below. It could have caused the error because there would be no variable called target.
The first line you deleted is there to prevent the code running too often. It will still work without it but will use the processor much more.
The second line is necessary, it prevents changes the code makes from triggering the macro again. I'm not sure but think it will just run and run and you won't be able to do anything else with it.

You are right about me copying E2 wrongly. As you guessed it should be C2.

These things have been corrected ibelow f you want to copy & paste.


Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)

    If target.Columns.Count <> 16 Then Exit Sub
    Application.EnableEvents = False
   
    If Cells(2, 5) <> "In Play" Then
        Cells(1, 24) = "NO"
        Cells(1, 25) = ""
        Application.EnableEvents = True
        Exit Sub
    End If
   
    If Cells(1, 24) = "NO" Then
        Cells(1, 24) = "WAIT"
        Cells(1, 25) = Cells(2, 3)
    End If
   
    If Cells(2, 3) - Cells(1, 25) >= TimeSerial(0, 0, 20) Then
        Cells(1, 24) = "OK"
    End If
   
    Application.EnableEvents = True
   
End Sub



I would recommend making a copy of your workbook (so you can go back to yours if you need to), then deleting all the code you have in it, then pasting my code into the worksheet code window. This is to make sure your code and my code are not clashing with each other.

Please let me know how you get on with it.
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby inplay » Tue Dec 26, 2006 6:56 pm

Hello Mitch

I thought worksheet_change only worked if I does some Input by hand and therefore used worksheet_calculate. :oops:

But now perfect. :lol:

The last code you post perfectly worked I could take it exactly so.

Much thanks for your help.

Maybe I can get ...... someday. :wink:

Cheers
Andy
Last edited by inplay on Wed Dec 27, 2006 6:39 pm, edited 1 time in total.
sorry for my bad English
User avatar
inplay
 
Posts: 16
Joined: Sun Dec 17, 2006 12:52 pm
Location: Germany

Postby Mitch » Wed Dec 27, 2006 5:51 pm

I'm glad I could help Andy......

..... and I hope the revenge thing is a bad translation :shock: :shock: ;)
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby inplay » Wed Dec 27, 2006 6:25 pm

was a very bad translation i have to buy a new dictionary :oops:

it should mean

to get one's own back (on)
to return the favour (favour)
to pay someone back
to take revenge (on) :roll:

I have this four in the Dictionary and take the last :twisted:

don't know that it was a bad word sorry Mitch :roll:

Cheers Andy
sorry for my bad English
User avatar
inplay
 
Posts: 16
Joined: Sun Dec 17, 2006 12:52 pm
Location: Germany

Postby Mitch » Wed Dec 27, 2006 7:55 pm

No problem, I knew what you meant.

Also, your English is far better than my <insert your language here> :D
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester


Return to Help

Who is online

Users browsing this forum: No registered users and 101 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.

cron