+ Reply to Thread
Results 1 to 5 of 5

Repeat Macro Code every 30 seconds for 2 hours and move down a cell

  1. #1
    Registered User
    Join Date
    10-22-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    3

    Repeat Macro Code every 30 seconds for 2 hours and move down a cell

    Hi

    So I have been struggling to get this to work.

    The vb code that i am using is to get data from a analytical balance. I have used the vb code from http://www.msc-lims.com/lims/diybalance.html

    Now the communication is via RS232.

    My problem is when I click the command button I get a single reading. I would like to repeat a macro(userform1) so I get continuous reading every 30 seconds for 2 hours.

    I have tried everything with no success,

    Loops with wait function,
    Timers (Application.OnTime Now...)

    Please help me out.

    Thanking you in advance

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: Repeat Macro Code every 30 seconds for 2 hours and move down a cell

    I think the loop would be this, assuming RequestBalanceData writes the data to the activecell. Start with the first cell selected.

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    10-22-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    3

    Re: Repeat Macro Code every 30 seconds for 2 hours and move down a cell

    Thank you for replying.

    I pasted your code under my commandbutton which is placed under sheet1. The main code is under UserForm1.

    So i modified your code so sub GetData() to my command button. But an error saying RequestBalanceData not defined.

    I changed that to UserForm1.RequestBalanceData and then "GetData" not defined.

    I am still trialling and modifying the code your wrote accordingly but still no success.

    Thanking you in advance

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: Repeat Macro Code every 30 seconds for 2 hours and move down a cell

    Don't use a userform. I think you need to move all your code (specifically, RequestBalanceData() ) to a standard codemodule, along with the macros that I posted. Based on the link that you provided, that should work.

  5. #5
    Registered User
    Join Date
    10-22-2014
    Location
    London
    MS-Off Ver
    2007
    Posts
    3

    Re: Repeat Macro Code every 30 seconds for 2 hours and move down a cell

    Thank you for all the help. Unfortunately moving my code wouldn't work as using ActiveX control from the userform.

    Anyways I have modified your code and using loops which seem to work for now.

    Thanks

+ 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. Macro to move code to cell, print, then move down the list to the next code
    By MilesDeep in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2014, 04:59 PM
  2. [SOLVED] Seconds to hours:minutes:seconds format
    By dalipsinghbisht in forum Excel General
    Replies: 1
    Last Post: 05-12-2013, 12:10 AM
  3. [SOLVED] Macro to move to next worksheet and repeat task
    By wakisme in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2012, 07:37 PM
  4. Replies: 7
    Last Post: 05-25-2012, 03:09 PM
  5. convert from seconds to form hours: minutes: seconds?
    By nguyen_han in forum Excel General
    Replies: 2
    Last Post: 10-13-2011, 06:56 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