Results 1 to 5 of 5

Thread: How to use DataBodyRange property to write to a specific sheet?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    Sub CopyPivot()
        Dim pvt As PivotTable
        Dim rng As Range
        For Each pvt In ActiveSheet.PivotTables
            With pvt
                .ColumnGrand = True
                .RowGrand = True
            End With
            Set rng = pvt.DataBodyRange
            rng.Cells(rng.Rows.Count, rng.Columns.Count).ShowDetail = True
            Selection.Copy Worksheets("Sheet3").Range("A1")
            Application.DisplayAlerts = False
            ActiveSheet.Delete
            Application.DisplayAlerts = True
        Next pvt
    End Sub
    Last edited by Aussiebear; 02-05-2025 at 01:36 AM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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