在Excel中,我想将两个动态命名范围一起添加到一个范围中,以用于单维图表系列。命名范围是单维的,并且始终具有匹配的宽度(列数)。
我在VBA中创建了一个结合命名范围的动态数组,但后来我了解到Excel图表需要静态数组,无法处理动态数组。
是否有关于如何根据组合动态命名范围分配图表系列的建议?
这些是命名范围:
OFFSET(IncData!$A$1,MATCH("Actual Units"&ReportMetrics!$B$1,IncData!$B:$B&IncData!$A:$A,0)-1,2,,COUNTA(IncData!$1:$1)-2)
OFFSET(IncData!$A$1,MATCH("Remaining Units"&ReportMetrics!$B$1,IncData!$B:$B&IncData!$A:$A,0)-1,2,,COUNTA(IncData!$1:$1)-2)
这是我想用于图表系列的数组:
Public Sub CurrentCombinedRemaining()
Dim Dates As Range
Set Dates = Application.Range("IncData!Date")
Dim CurrentRemaining As Range
Dim CurrentActuals As Range
Dim Spread() As Variant
Dim rCount As Integer
rCount = Dates.Count
ReDim Spread(rCount)
Dim i As Integer
Set CurrentRemaining = Application.Range("IncData!CurrentRemaining")
Set CurrentActuals = Application.Range("IncData!CurrentActuals")
For i = 1 To rCount
Spread(i) = CurrentRemaining.Cells(, i).Value + CurrentActuals.Cells(, i).Value
Next i
End Sub