+ Reply to Thread
Results 1 to 5 of 5

the MACRO that find last row above the total row in table and add the new row

  1. #1
    Registered User
    Join Date
    01-07-2013
    Location
    Sari, Iran
    MS-Off Ver
    Excel 2007
    Posts
    3

    Lightbulb the MACRO that find last row above the total row in table and add the new row

    Dear Friends
    hi
    this is my first post in this forum, i'm so glad to find this site and you
    i try to assigned the MACRO to shape in worksheet that add a new row above a total row
    but all macro just point to specific row number like bellow:

    Sub Add()
    '
    ' Add Macro
    '

    '
    Rows("12:12").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End Sub

    would you please help me in this issue

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: the MACRO that find last row above the total row in table and add the new row

    For a table named "myTable" on Sheet1, this VBA code inserts a new row immediately above the total row of the table

    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    01-07-2013
    Location
    Sari, Iran
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: the MACRO that find last row above the total row in table and add the new row

    Dear Ron
    so many thanks for your helpful reply,
    it is done

    if it is possible, i want to copy some formula from above row, what should add to VBA
    for example i have following formula in one cell (G38):

    ='Sheet1'!$E38-'Sheet1'!$F38

    if possible the new row have same formula on same cell (G39):

    ='Sheet1'!$E39-'Sheet1'!$F39



    thanks for your kind support

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: the MACRO that find last row above the total row in table and add the new row

    As long as the formula is either adjacent to or part of the table, Excel will copy the formula into the new row when the macro inserts it. Does that help?

  5. #5
    Registered User
    Join Date
    01-07-2013
    Location
    Sari, Iran
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: the MACRO that find last row above the total row in table and add the new row

    Dear Mr.Ron
    first of all thanks for useful advises
    kindly you can find [ware house report.xlsx] in attached file.
    i want when i click on the green shape at right top of first sheet("Add new Row") following items be happen:

    1- add the row at last row top of total row
    2- copy formula from top row
    3-add another sheet at the end of exist sheet with the same shape of existing sheet

    if it is possible with VBA, It would be greatly appreciated if you please help me in this regard
    Attached Files Attached Files

+ 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