+ Reply to Thread
Results 1 to 7 of 7

Automatically add new row to worksheet IF dynamic table above expands?

  1. #1
    Registered User
    Join Date
    03-06-2021
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    9

    Automatically add new row to worksheet IF dynamic table above expands?

    Hi,
    I am a complete novice with VBA. I normally try and use formulas in cells to get through. However I think my latest problem has stumped me, and is beyond the scope of a formula in a cell.

    What I really need is a code to add an extra row under a dynamic table as it expands, so that it is always separated from any data below it.

    Overview - I have a dynamic table with Staff details and their leave entitlements for the year.
    I also have some analysis data below the dynamic table.
    In real life there are more than 30 staff per sheet/location, and 5 different rows of data analysis underneath. However I've tried to keep it simple in the example.

    I need the staff table above to remain dynamic as there are hidden formulas and other formatting I need to expand with the table as we add/remove staff members.

    The problem is that obviously dynamic tables are only able to expand as far as the empty rows below it. Once it reaches the analysis data, it stops expanding dynamically. So what I really need is a code to add a row under the dynamic table as it expands, so that it is always separated from the data below it.

    I have tried adding a code that when column "A" exceeds X amount of entries (10 in the sample data), it'll add another row automatically. This hasn't worked.

    Can anyone please help?
    Thanks in advance!

    ETA - Here is what I tried

    Sub MyInsertRow()

    Dim lastRow As Long

    lastRow = Cells(Rows.Count, "A").End(xlUp).Row

    If lastRow >= 10 Then
    Rows(lastRow + 1).Insert

    End Sub
    Attached Files Attached Files
    Last edited by aussie.lilly; 04-21-2021 at 09:46 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Automatically add new row to worksheet IF dynamic table above expands?


    Hi,

    according to your attachment any VBA code is necessary with a 'dynamic' table !

    Just right click on the table to add or delete a row then the data below moves accordingly …

  3. #3
    Registered User
    Join Date
    03-06-2021
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    9

    Re: Automatically add new row to worksheet IF dynamic table above expands?

    Quote Originally Posted by Marc L View Post

    Hi,

    according to your attachment any VBA code is necessary with a 'dynamic' table !

    Just right click on the table to add or delete a row then the data below moves accordingly …
    Thanks for that,
    Yes I know it can expand automatically if you right click and add new row. This is great for me but there will be 27 other managers at different sites, most with minimal excel experience, accessing a version of this workbook and I guess I want to try and make it as user friendly as possible.

  4. #4
    Registered User
    Join Date
    03-06-2021
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    9

    Re: Automatically add new row to worksheet IF dynamic table above expands?

    When I sent my version to a colleague to test, they just wrote each staff name under the last one, which ran into problems obviously when they reached the data analysis section. I want to try and cater for everyone, as this will be sent to 27 different sites/managers with varying levels of excel experience. Each site also has varying amounts of staff members (some sites have 10 staff and others have 50, although most are over 30) so I also can't just "preset" the number of rows and place the analysis table accordingly

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question


    As the easy way is to move the part under the table just above : no issue, no code …

    Or maybe just protecting the worksheet, did you try ?

  6. #6
    Registered User
    Join Date
    03-06-2021
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    9

    Re: Automatically add new row to worksheet IF dynamic table above expands?

    If I protect the whole sheet, they won't be able to enter data.
    If I protect the sheet but set an editable range (the table), the dynamic table doesn't expand or allow addition of rows.

    I did ask about shifting the data analysis above the table but it seems that isn't acceptable, as everyone wants the totals and analysis at the bottom of each column for reference

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: Automatically add new row to worksheet IF dynamic table above expands?


    An easy way could be to detect any manual entry outside the table in order to prompt a message that is forbidden, must use the right click …

+ 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. How to change a number to increase in size as the table expands
    By LinaL in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-04-2018, 04:40 PM
  2. How to change a number to increase in size as the table expands
    By LinaL in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-02-2018, 09:47 AM
  3. Duplicate formula in rows as pivot table expands
    By vrinner in forum Excel General
    Replies: 1
    Last Post: 02-05-2018, 03:50 PM
  4. Formulas not added as table expands
    By mjcarman01 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-27-2017, 02:27 PM
  5. Replies: 3
    Last Post: 03-27-2017, 04:59 PM
  6. Dynamic named range that expands "horizontally"
    By adelkam in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-19-2016, 11:07 AM
  7. [SOLVED] Vlookup on Dynamic Range that expands vertically and horizontally
    By huy_le in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-27-2013, 03:47 PM

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