+ Reply to Thread
Results 1 to 6 of 6

VBA to copy grand total in Pivot table

  1. #1
    Registered User
    Join Date
    03-28-2013
    Location
    thailand
    MS-Off Ver
    Excel 2003
    Posts
    25

    VBA to copy grand total in Pivot table

    Hi. I have a sheet where I use VBA to perform a few calculations with a pivot table.

    1) I would like the GRAND TOTAL ROW of the pivot table to be copied and pasted 5 rows below the grand total row. Problem is the grand total row is dynamic and dependent on the data in column A of the pivot table. I need the VBA to copy the "dynamic and moving" grand total row wherever it is

    2) I would like the second (third and forth, etc....) set of results to be pasted below the first row. Then the third results below the second results. The first row of results is also "dynamic and moving" since it is 5 row below the grand table.

    I am very new to VBA and normally I use the recording function.

    In this example, The grand total is at row 52 but VBA to select the grand total row. Row 102 is where I pasted first the data but I want it to be 5 rows below the grand total. The second set of results need to be pasted 1 row below the first set of results.

    Rows("52:52").Select
    Selection.Copy
    Rows("102:102").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    GETTING SECOND OF RESULTS to be pasted below the first set of results.

    Rows("52:52").Select
    Selection.Copy
    Rows("103:103").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: VBA to copy grand total in Pivot table

    I probably understand you. Can you please attach a Sample Sheet?
    Cheers!
    Deep Dave

  3. #3
    Registered User
    Join Date
    03-28-2013
    Location
    thailand
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA to copy grand total in Pivot table

    File is attached
    Attached Files Attached Files

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: VBA to copy grand total in Pivot table

    Please see the file attached.

    Please revert if this what not what you were looking for..

    Thank You,

    Deep
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-28-2013
    Location
    thailand
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA to copy grand total in Pivot table

    Thank you sir. It works very well

  6. #6
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: VBA to copy grand total in Pivot table

    Glad it helped!



    Cheers!

    Deep

+ 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