+ Reply to Thread
Results 1 to 12 of 12

Macro to keep inserting table rows until #NA errors are reached in Columns K & L

  1. #1
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    Hi,
    Is there a code or formula that will keep inserting formula rows below until #NA errors are reached in both columns K & L in Table2?

    The idea here is to always keep an open Excel row in Table2 that is ready to receive data from Table1. I would like a solution that is dynamic or will automatically maintain an empty row at the bottom of Table2 as data is entered in the Table1 columns.

    Right now in the attached worksheet, in row 8, there is a 2/12/20 date in cell J8 and #N/A errors in cells K8 and L8. As new rows with data are added to the bottom of Table1, row #8 of Table2 will eventually have numbers in the K & L column cells and I would like a new row #9 with #N/A errors in cells K9 and L9 to automatically appear.

    I'm hoping knows of a macro solution that is able to keep adding on formulated table rows down the columns until both K and L column cells in the same row have #N/A errors in them.
    Attached Files Attached Files

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    Possibly with the worksheet's change event...
    Please Login or Register  to view this content.
    or as a standard macro...
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    Hi dangelor,

    The first macro works very well. Noticed, however, that I needed to make sure that the two targeted columns do NOT calculate with blanks or else the code will insert blank rows all the way to the bottom of the sheet.

    I couldn't get the second one to work consistently. Not sure but it could be an error on my part in how I tried to work it.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    Not sure, but does this catch the blank rows?
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    Thanks for the suggestion.
    It still works well when the table calculates to NA(). However, when the target cells calculate to blank, it still keeps inserting rows down.

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    Any chance of uploading a workbook to analyze?


    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  7. #7
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    Sorry this took so long. I was gone from the computer the past few days.


    Here's the file. I had changed the formulas in the target columns to calculate to blank instead of NA(), then this happened to the worksheet.
    If I kept it at NA(), it works fine.

    Thanks for looking at this!
    Attached Files Attached Files

  8. #8
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    This seems to work...
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    dangelor,

    I appreciate your efforts. However, I'm not getting anything to happen with this code. Is it because I'm not doing something correctly? I keep going back to this but can't figure it out.

    Here's the file I tried the macro with.
    Attached Files Attached Files

  10. #10
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    The formulas for Count Avg and Duration Avg are different.

  11. #11
    Forum Contributor
    Join Date
    05-25-2019
    Location
    Sioux Falls, South Dakota
    MS-Off Ver
    Microsoft 365
    Posts
    178

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    dangelor,
    Turns out that the first macro you offered works just perfect for what I needed. Thank you!

    The goal was to somehow get table 2 to update whenever data is entered in table 1. This macro does that. I finally figured out I should write the formulas in table 2 to calculate to either data or N/A errors. This allows Table2 to be used for charting purposes without having to manually enter data into Table2.

    I hope others find this post useful for their purposes as well.

  12. #12
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Macro to keep inserting table rows until #NA errors are reached in Columns K & L

    Glad it's working!

+ 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. VBA, excel : deleting/inserting rows , no errors, no result
    By ArnoldHatCGI in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2020, 11:45 AM
  2. Replies: 4
    Last Post: 12-12-2018, 12:34 AM
  3. Inserting filter into pivot table via macro errors if filter doesn't exist.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2018, 10:24 AM
  4. Need Macro to match two different columns and inserting blank rows
    By michael.adams2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2017, 04:33 PM
  5. Replies: 1
    Last Post: 05-30-2015, 03:12 PM
  6. [SOLVED] Inserting columns and rows at the end of table with border
    By evilr34 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2013, 02:47 PM
  7. Replies: 5
    Last Post: 11-12-2008, 05:44 AM

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