且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Excel-从数据透视表中提取一列并将其显示在常规表中

更新时间:2023-01-30 21:56:23

我之前已经编写了一些代码,以将表从属到数据透视表,这样,数据透视表的尺寸或位置的任何变化都将反映在阴影表的尺寸上和位置.这有效地为我们提供了一种将计算的字段添加到数据透视表中的方法,该字段可以引用该数据透视表之外的内容.如果数据透视表增长,则计算表将增长.如果数据透视表缩小,则计算表"将缩小,并且其中的所有冗余公式都将被删除.该表可以轻松引用数据透视表,也可以基于该数据透视表中的信息引用其他内容.

I've previously written some code to slave a Table to a PivotTable, so that any change in the PivotTable's dimensions or placement will be reflected in the shadowing Table's dimensions and placement. This effectively gives us a way to add a calculated field to a PivotTable that can refer to something outside of that PivotTable. If the PivotTable grows, the Calculated Table will grow. If the PivotTable shrinks, the Calculated Table will shrink, and any redundant formulas in it will be deleted. That Table can easily reference the PivotTable, or it can reference something else based on information in that PivotTable.

请参见选择最新记录并在Excel中创建唯一值的新表

这些示例图像显示了两件事:

These sample images show two things:

  1. 表格将按照大小跟踪数据透视表
  2. 您可以在该表内实现所需的任何公式逻辑.例如,这里我根据数据透视表中显示的Reg No在源表上进行查找.