M
Microsoft Forum
Hi all,
In the VBA online help it says that the SourceData property accepts "an
array of ranges". If this is true, may anyone advise why the following code
failed? Thanks.
Sub CreatePivot()
Dim MonthlyData(1 To 12) As Range
Dim i As Integer
For i = 1 To 12
Set MonthlyData(i) = Worksheets(i).Range("A1").CurrentRegion
Next
ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:=MonthlyData, _
tablename:="YearlySales"
End Sub
Frederick Chow
Hong Kong.
In the VBA online help it says that the SourceData property accepts "an
array of ranges". If this is true, may anyone advise why the following code
failed? Thanks.
Sub CreatePivot()
Dim MonthlyData(1 To 12) As Range
Dim i As Integer
For i = 1 To 12
Set MonthlyData(i) = Worksheets(i).Range("A1").CurrentRegion
Next
ActiveSheet.PivotTableWizard _
SourceType:=xlDatabase, _
SourceData:=MonthlyData, _
tablename:="YearlySales"
End Sub
Frederick Chow
Hong Kong.