我创建了下面的宏它的工作正常..我想选择值来动态结束Row而不是$ A $ 3:$ A $ 328 ..类似Range(" A3"& Rows.Count) ).END(xlUp).Row
任何人都可以帮助我
Private Sub CommandButton1_Click()
Dim arrCharts, cht
Dim wb As Worksheet
Dim wbTarget As Workbook
Dim sh As Worksheet
Set wbTarget = Workbooks.Open(Filename:="C:\Users\mahather\Desktop\Report\Summary Report.xlsx")
Set wb = wbTarget.Worksheets("Graph")
Set sh = wbTarget.Worksheets("Summary")
arrCharts = Array("Chart 2", "Chart 5")
For Each cht In arrCharts
With wb.ChartObjects(cht).Chart
.SeriesCollection(1).XValues = "='Summary'!$A$3:$A$328"
End With
Next cht
End Sub
答案 0 :(得分:1)
您可以使用以下代码
Dim LastRow As Long
LastRow = ThisWorkbook.Sheets("Summary").UsedRange.Rows(ThisWorkbook.Sheets("Summary").UsedRange.Rows.Count).Row
然后为每个
编辑下面一行 .SeriesCollection(1).XValues = "='Summary'!$A$3:$A$" & LastRow
如果有帮助,请告诉我。