【发布时间】:2021-09-22 11:29:40
【问题描述】:
进一步说 Amending all Charts
- @CDP1802 非常友好地解决了问题 - 再次感谢 -
我傻了。 . . 我还需要扩展图表上出现的线条,即
Private Sub Workbook_Open()
Option Explicit
Dim ws As Worksheet, cht As ChartObject, n As Integer, dt As Date
Dim myLastRow As Integer, myRow As Integer
Sheets("Record").Select
' Go to last entry
myLastRow = ActiveCell.SpecialCells(xlLastCell).Row
myLastRow = Range("H" & myLastRow).End(xlUp).Row
Range("D" & myLastRow).Select ' Don't ask !
' Extend Column A so that the last entry is a week from today.
' Also extend predictions
myRow = myLastRow
Do Until Range("A" & myRow) >= Now() + 7
myRow = myRow + 1
Range("A" & myRow) = Range("A" & myRow - 1) + 1
If myRow > myLastRow + 1 Then
Range("B" & myRow & ":G" & myRow) = Range("B" & myRow - 1 & ":G" & myRow - 1)
End If
Loop
dt = Date + 7
For Each ws In ThisWorkbook.Sheets
For Each cht In ws.ChartObjects
cht.Chart.Axes(xlCategory).MaximumScale = dt
For every Line in the Chart
If the X-axis is Sheet("Record").Column A Then
Extend the line (Column A and its own Column) down to myRow
End If
Next Line
Next
Next
End Sub
【问题讨论】:
标签: excel vba excel-charts