+ Reply to Thread
Results 1 to 4 of 4

VBA for Lucky draw displaying numbers

  1. #1
    Registered User
    Join Date
    11-26-2015
    Location
    Shanghai, China
    MS-Off Ver
    2010
    Posts
    4

    VBA for Lucky draw displaying numbers

    I'm trying to write a simple VBA for a Lucky draw for a charity event here. Unfortunately I've misjudged my VBA knowledge a bit, I'm rusty...

    My aim:
    Have one cell quickly display a random number within a predefined range of numbers and stop this with a stop button.

    Sofar I have this code:

    Sub startTimer()
    Application.OnTime Now + TimeValue("00:00:01"), "Increment_count"
    End Sub

    Sub Increment_count()
    Range("A3").Value = Range("A3") + 1
    startTimer
    End Sub

    Sub StopTimer()
    Application.OnTime Now + TimeValue("00:00:01"), "Increment_count", Schedule:=False
    End Sub

    The problem now is:
    1. I need to limit the range as specified in 2 cells (from and to range). (now it just runs up indefinitely)
    It should keep running till I click the stop button.
    2. I would prefer the numbers to be displayed randomly
    3. The change in numbers is far too slow (1 per second)

    Any help will be greatly appreciated,
    Tnx

    Jan

  2. #2
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: VBA for Lucky draw displaying numbers

    Hi @Jan Van der Borght

    As far as I know, the OnTime works with increments no lower than 1 second

    I've attached a file to do what you asked for:
    It has start and stop buttons
    it counts every 0.2 seconds
    you define max and min values, and it returns a random number between those limits changing every 0.2 seconds

    I hope it solves your needs
    Vicho
    Attached Files Attached Files
    Barriers are there for those who don't want to dream

  3. #3
    Registered User
    Join Date
    11-26-2015
    Location
    Shanghai, China
    MS-Off Ver
    2010
    Posts
    4

    Re: VBA for Lucky draw displaying numbers

    Hi Vicho,

    Works like a jem, Thank you so much.
    We're going to project this during the event.

    Grtz

    Jan

  4. #4
    Valued Forum Contributor
    Join Date
    08-07-2014
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2016 & 365, Windows 10
    Posts
    511

    Re: VBA for Lucky draw displaying numbers

    Glad to know it worked for you.
    you are welcome

    Vicho

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Random name generator with no duplicates for company's lucky draw segment
    By nekolaypeng in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-09-2014, 05:39 AM
  2. Hello and Thank My Lucky Stars I Found This Site!!
    By Reets90 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 04-02-2014, 08:38 PM
  3. Hello - I try to run before I can walk, painful but occasionally lucky
    By garvan in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 07-29-2013, 09:22 PM
  4. Return I'm Felling Lucky Url From Google Search
    By rogers14223 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2012, 04:24 PM
  5. [SOLVED] HELP: Get Hot and Cold numbers for each draw in Excel ?
    By Mr.Nob0OOdy in forum Excel General
    Replies: 7
    Last Post: 06-27-2012, 09:01 AM
  6. Create Lucky Draw game in Excel or PowerPoint
    By alibaba in forum Excel General
    Replies: 1
    Last Post: 10-23-2009, 01:16 AM
  7. Can you draw lines through the center of cells, using cell numbers as references?
    By iterature in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2007, 06:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1