引用整个数据透视表的公式?

发布于 2024-08-08 01:39:26 字数 117 浏览 3 评论 0原文

我有一堆包含详细数据集和数据透视表的工作表。在摘要表上,我想仅显示数据透视表。 (当然,我宁愿保持干燥,而不是创建一个全新的集合。)我如何引用旧的数据透视表?

如有必要,我可以使用 VBA 来完成此操作。

I have a bunch of sheets with detailed data sets and pivot tables. On a summary sheet, I want to display just the pivot tables. (Of course, I'd rather stay DRY and not create a whole new set.) How can I reference the old pivot tables?

I can use VBA to do this if necessary.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

活雷疯 2024-08-15 01:39:26

该子程序将使数据透视表保持“活动”状态。如果您不想这样做,您可以将 PasteValues 覆盖在它们上。

Sub SummarizePivotTables()
    Dim wb As Workbook, ws As Worksheet, ss As Worksheet, pt As PivotTable
    Dim pasteRow As Long
    Const rowsBetween As Long = 1

    Set wb = ThisWorkbook
    Set ss = wb.Worksheets("Summary")
    pasteRow = 1 'first table row'

    For Each ws In wb.Worksheets
        For Each pt In ws.PivotTables
            'change this to TableRange1 if you do not want the page field included'
            With pt.TableRange2
                .Copy ss.Range("A" & pasteRow)
                pasteRow = pasteRow + .Rows.Count + rowsBetween
            End With
        Next pt
    Next ws
End Sub

This sub will keep the pivot tables 'live.' You could PasteValues over them if you don't want that.

Sub SummarizePivotTables()
    Dim wb As Workbook, ws As Worksheet, ss As Worksheet, pt As PivotTable
    Dim pasteRow As Long
    Const rowsBetween As Long = 1

    Set wb = ThisWorkbook
    Set ss = wb.Worksheets("Summary")
    pasteRow = 1 'first table row'

    For Each ws In wb.Worksheets
        For Each pt In ws.PivotTables
            'change this to TableRange1 if you do not want the page field included'
            With pt.TableRange2
                .Copy ss.Range("A" & pasteRow)
                pasteRow = pasteRow + .Rows.Count + rowsBetween
            End With
        Next pt
    Next ws
End Sub
能否归途做我良人 2024-08-15 01:39:26

数据透视表在工作簿中称为“Excel 表”。因此,您应该能够在没有 VB 的情况下执行此操作,如我在此答案中所述

太长;博士;

  • 数据->获取外部数据->现有连接
  • 转到“表”选项卡,选择您的表
  • 插入为“表”

Pivot tables are named "Excel tables" in your workbook. So you should be able to do this without VB as I described in this answer.

tl;dr;

  • Data -> Get External Data -> Existing Connections
  • Goto "Tables" tab, select your table
  • Insert as "Table"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文