+ Reply to Thread
Results 1 to 5 of 5

Macro to Insert Row below but above total row

  1. #1
    Registered User
    Join Date
    08-26-2011
    Location
    Birmingham AL
    MS-Off Ver
    Excel 2007
    Posts
    11

    Macro to Insert Row below but above total row

    I need a macro to insert an empty row above the total row below the row I am typing in. For example, see attached sheet, when I start typing in A5 I want a macro to automatically insert a row below row 5 above the "total" row with the same formatting as the row above.
    I have multiple sheets on a spreadsheet that all have the same columns however the number of rows is different. I need to be able to have this macro run above the total row in each spreadsheet.
    Is this possible?
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Macro to Insert Row below but above total row

    Try pasting the following into the ThisWorkbook tab in the VBA editor (Alt F11).

    Please Login or Register  to view this content.
    Martin

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro to Insert Row below but above total row

    Hello cynd301,

    Welcome to the Forum!

    The attached workbook has the macro shown below already added. This macro allows the table to start anywhere on the worksheet as long as it is the first group of data on the worksheet. The headers are always the first row of the table and the total row must have the word "Total" in it. A blank row is automatically added when needed above the total row. Additionally, this macro allows you to construct a table on worksheet if you need to.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    08-26-2011
    Location
    Birmingham AL
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Macro to Insert Row below but above total row

    My apologies for the delay in my response, I got called away on two other projects.

    Thank you so much for helping me with this issue. I can only hope to one day have the macro skills you do. You have totally made my day.

  5. #5
    Registered User
    Join Date
    09-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Macro to Insert Row below but above total row

    Hi Leith

    I know this is a rather old topic but I had a question and would really appreciate it if you could help.

    I tried the above macro and it works a treat of the data is type in the above cells - a new row is added. However, a new row isnt added if data is entered via a macro as opposed to being typed. The macro simply writes over the 'total' row. How can I get around this ?

    Many thanks

    Roger

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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