+ Reply to Thread
Results 1 to 9 of 9

add rows each x minutes to table wich fixed # of rows.

  1. #1
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    add rows each x minutes to table wich fixed # of rows.

    In my workbook, I get live data across a few columns (through a data connection). This data changes every x minutes. Lets say that's in row 1.

    Beneath this is a table exactly 300 rows deep. (e.g. rows 2 through row 301)

    I want row 301 to show the most recent data from row 1, then when x minutes passes, the data in row 301 is pushed up to row 300... all the way up. Whatever was in row 2 "falls off the cliff" so to speak.

    Is there a formula which can do this rather than a macro?

    And, if it has to be a macro, can multiple macros run in the same workbook (perhaps if macro A is running, macro B waits until A is done)?

    Thanks

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

    Re: add rows each x minutes to table wich fixed # of rows.

    You can do what you want with formulas if you have a sheet that continues to accumulate new data at the bottom.

    Create a new table with this formula in cell A2:

    =INDEX(DataSheet!A:A,ROW(A1)+MAX(1,COUNTA(DataSheet!A:A)-299))

    and drag down for 300 rows, and across for as many columns as you need. This assumes that your headers on DataSheet are in row 1, there are no gaps in your data, and the newest data is added to a blank row at the bottom of your sheet DataSheet.

    If I got the logic backwards - post back.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: add rows each x minutes to table wich fixed # of rows.

    Thanks Bernie. My concern is that our live data updates every 5 minutes. This translates to about 17,000 cells/month if we were to simply have a raw data sheet like the one you suggest (using 10 columns of data). I wonder if we could have a simple macro that deletes the top (or bottom) x rows periodically on the data sheet?

    The workbook is fairly complex so I'm trying to make it as lean as possible.

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

    Re: add rows each x minutes to table wich fixed # of rows.

    Add code like this, that deletes values starting from the top of the sheet, leaving the header row and 300 rows of data on sheet Data. Start the code by calling CleanUp from the workbook open event, and call StopIt from the workbook before close event. The macro is run every 5 minutes, but you can change that to a longer time period if it doesn't bother you to have more data. You could really just do it every time you open the workbook, unless the workbook is never closed.


    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: add rows each x minutes to table wich fixed # of rows.

    Thank you Bernie. I'm a little dense on how to implement all this. Is the macro to be used instead of the formula you suggested, or do we create two worksheets so that one of them simply appends new data to the last row, and the other keeps the rows limited to 300?

    Note that there will be 10 tables on the worksheet. (I'm only showing 2).

    Rows 1 and 2 are Headers.

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

    Re: add rows each x minutes to table wich fixed # of rows.

    Yes - the macro is in place of the formula. It will work on one worksheet to keep the number of rows to 301 - 1 header row and 300 rows of data. No need for a second worksheet.

    I don't see the tables - if they are all horizontally spread out and each is limited to 300 rows..... maybe an example workbook showing your table structure, and an explanation of what you really want....

  7. #7
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: add rows each x minutes to table wich fixed # of rows.

    Bernie, here's a second template filled with data.

    Let me know if this helps.

    Thanks so much for helping me.

    PS there will be 10 tables, all structured exactly the same.
    Attached Files Attached Files

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

    Re: add rows each x minutes to table wich fixed # of rows.

    The attached doesn't currently have the data connection but the code will start running when you open it, and run every 5 minutes thereafter. It will stop the process when you close the workbook.

    I have changed the code to keep the tope two rows with the headers.

    Let me know....
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: add rows each x minutes to table wich fixed # of rows.

    Thank you Bernie. This helped.

+ 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. Replies: 13
    Last Post: 10-13-2015, 04:17 AM
  2. Possible VBA for adjusting fixed table banded rows with pivot table banded rows
    By Gunner182 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-14-2015, 03:44 PM
  3. macro to import varying data rows into fixed table
    By aselly22 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-29-2014, 12:51 AM
  4. [SOLVED] VBA Pivot Table with Fixed Rows
    By excelnewbie80 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-09-2013, 10:02 AM
  5. Replies: 0
    Last Post: 08-30-2010, 10:30 PM
  6. Insert rows alternatively in Pivot Table to calculate percentage of fixed ranges
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2008, 12:19 PM
  7. Fixed rows
    By tortuga0981 in forum Excel General
    Replies: 4
    Last Post: 01-23-2007, 06:30 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