[VBA:添加新的数据行时更新图表

问题描述 投票:0回答:1

我正在研究在将新信息添加到数据表时以及在视频或过滤器角钱行时刷新图表的宏

但是,任何时候我向数据表添加新行时,图表格式都是错误的。请帮助我:(。这是我的代码:

Sub RangeRefresh()
 Dim vAddress As range, n As Long, c As range
 Dim lastRow
 lastRow = Cells(Rows.Count, "A").End(xlUp).Row

With Sheets("Chart1").SeriesCollection(1)
 Set vAddress = Sheets("Sheet1").range("A2:A" & lastRow & ",B2:B" & lastRow)

        n = 0 'for counting visible datapoints

    For Each c In vAddress.Cells

       'is the row visible? skip if not
       If Not c.EntireRow.Hidden Then
       n = n + 1 'next visible datapoint
       End If                            
   Next 
   End Sub
excel vba rows excel-charts
1个回答
0
投票

我不确定是否确切理解“图表格式为错误”的意思,所以我希望我对这个答案是正确的。

© www.soinside.com 2019 - 2024. All rights reserved.