Results 1 to 20 of 104

Thread: Creating Multiple Tables Using Loop in VBA. I still want to add new sheets and add

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #30
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,970
    Snippet for you:
    Sub blah()
    Set PT = Sheets("Sheet6").Range("B6").PivotTable
    Set Destn = Sheets("Sheet6").Cells(Rows.Count, "W").End(xlUp).Offset(3)
    With PT
      Set pf = .PageFields("Tenure")
      For Each pit In pf.PivotItems
        pf.CurrentPage = pit.Name
        With .TableRange1
          .Copy
          Destn.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
          Application.CutCopyMode = False
          Set myTable = Sheets("Sheet6").ListObjects.Add(xlSrcRange, Destn.Resize(.Rows.Count, .Columns.Count), , xlYes)
          myTable.TableStyle = "TableStyleMedium14"
          myTable.ShowTableStyleRowStripes = False
          Set Destn = Destn.Offset(.Rows.Count + 2)
        End With    '.TableRange1
        myTable.Unlist
      Next pit
    End With    'PT
    End Sub
    Last edited by p45cal; 01-27-2020 at 08:23 AM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •