Consulting

Results 1 to 4 of 4

Thread: Solved: Excel Code running too fast

  1. #1

    Solved: Excel Code running too fast

    Hello friends,

    I have built this car race temp. /game and the codes run smoothly, but require some tweaking:
    Problem is : While the code "A" is running, the range I22:R22 should show the movement of the cars (conditional format). The codes are fine, but the artificial visual effect is not happening because the code is running too fast. Is there any way around that? To show the effect of cars racing/skipping cells.

    I hope I was able to explain what I need to achieve. If anything seems vague let me know, I would be glad to explain more.

    Thanks a lot in advance!
    Nawaf
    Last edited by countryfan_n; 01-04-2009 at 04:49 AM. Reason: Too many questions in 1 post

  2. #2
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Hi Nawaf,
    At lot of can't/won't open attachments to see the code, so it might be good to post the pertinent bits. However, just as an offhand remark, have you taken a look at the Excel.Application.Wait method?
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Greetings Nawaf,

    Quote Originally Posted by countryfan_n
    ...but the artificial visual effect is not happening because the code is running too fast. Is there any way around that? To show the effect of cars racing/skipping cells...
    Reference problem number one only: I'm at home and on my "poor ol' laptop", so maybe I'm missing the boat as to the 'running too fast', but I don't think that is the initial problem. I don't see anywhere where the (wow, my language skills are suffering a bit...) cars are 'updating'.

    I understand why you shut screen updating off at the start, due to all the Selecting that your code is currently doing, but at some point, you need to momentarily turn it back on to show the cars advance.

    For a simple "first step" only, try this > in Sub F(), right below:

    Application.CutCopyMode = False

    Insert:

    [vba] Application.ScreenUpdating = True
    DoEvents
    Application.ScreenUpdating = False[/vba]

    Now depending upon the speed of your PC, you may well then need to consider Aaron's suggestion as to Application.Wait to then slow things down a bit, but I'm fairly sure that the current issue is as stated, nothing is updating visually until the race is already over. Hope that made sense?

    Mark

  4. #4
    Thank you so much for helping me with my post, Truly appreciate it.

Posting Permissions

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