VBA, Pivot Show Detail, Create to the right not the left

  • Hi,


    I have some VBA to automate the pivot drill down as part of a larger VBA project and I was hoping for some guidance.


    Essnetially the code works, but it creates sheets to the left of the original pivottable and I want to create sheets gonig to the right.


    The code, and it does work is as follows:





    I think I just need to add something to get it to output to the right.


    Hopefully this is very simple and I appreciate your help.


    Thanks


    Matt

  • Re: VBA, Pivot Show Detail, Create to the right not the left


    If you want to have the detail sheet to the immediate right of Sheet1 try:

    Code
    Sheet1.Range("E9").ShowDetail = True 
      ActiveSheet.Name = cc & " | " & Format(Now, "mm-ss") 
      ActiveSheet.Move After:=Sheet1


    if you want to move the newly created sheet to the very end try:

    Code
    Sheet1.Range("E9").ShowDetail = True 
      ActiveSheet.Name = cc & " | " & Format(Now, "mm-ss") 
      ActiveSheet.Move After:=Sheets(ThisWorkbook.Sheets.Count)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!