捕获时间线切片器中更改日期范围并更新图表

发布于 2025-01-21 11:40:36 字数 334 浏览 0 评论 0原文

我试图弄清楚当日期范围在时间轴切片机内更改日期范围时是否有办法捕获事件。

我要完成的工作是:

  • 我需要
  • 在更改日期范围时捕获时间轴切片机内的日期范围更改事件,使我的图表更新数据。

现在发生的事情是,当我更改时间表切片机中的日期范围时,连接的枢轴表被相应而瞬间更新,但是从这些枢轴表的某些字段中获取数据的图表(它们不是Pivot Charts 它们, )需要保存工作簿操作,然后才能更新新数据。

我使用仅连接到枢轴表的某些部分的图表的原因是,以这种方式,图表比枢轴图表更可自定义。

预先感谢您将我指向正确的方向

I am trying to figure out if there is a way to capture the event when a date range is changed within a timeline slicer.

What I am trying to accomplish is:

  • I need to capture the date range change event within the timeline slicer
  • have my charts updating data when the date range is changed.

What happens now is that when I change the date range in my timeline slicer the connected pivot tables are updated accordingly and instantaneously but the charts that take data from some fields of these pivot tables (they are not pivot charts) need a save workbook action before they can get updated with new data.

The reason why I am using charts connected to only some parts of my pivot tables is that in this way charts are more customizable than pivot charts.

Thank you in advance for pointing me towards the right direction

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

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

发布评论

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

评论(1

鸢与 2025-01-28 11:40:36

假设您不想将工作簿计算更改为“自动”,而只想更新图表,则以下是基本上剪切图表并在枢轴表更改时将它们粘贴到同一位置的代码。

Private Sub Worksheet_Change(ByVal Target As Range)

Dim myChart As ChartObject
Dim myCharts As ChartObjects
Dim myChartname As String
Dim strAddress As String

Set myCharts = ActiveSheet.ChartObjects

For Each myChart In myCharts
    myChartname = myChart.Name
    strAddress = myChart.TopLeftCell.Address
    ActiveSheet.ChartObjects(myChartname).Cut
    ActiveSheet.Paste Destination:=Range(strAddress)
Next

End Sub

Assuming you don't want to change Workbook Calculation to Automatic and just want to update the chart(s), below is the code to basically cut the chart(s) and paste them in the same place whenever the pivot table changes.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim myChart As ChartObject
Dim myCharts As ChartObjects
Dim myChartname As String
Dim strAddress As String

Set myCharts = ActiveSheet.ChartObjects

For Each myChart In myCharts
    myChartname = myChart.Name
    strAddress = myChart.TopLeftCell.Address
    ActiveSheet.ChartObjects(myChartname).Cut
    ActiveSheet.Paste Destination:=Range(strAddress)
Next

End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文