Excel VBA Pivot Table multiple workbooks data transfer

Tommy1370

New Member
Joined
Jul 23, 2013
Messages
13
User selects the data source file and data is pulled from the pivot tables to populate a table in another workbook.

Code:
Dim SourceFolderLocation As String
Dim FileName As String
Dim SourceFile As VariantMsgBox "Please select the data source file..."
SourceFolderLocation = "C\Users\UserName\Desktop"
ChDrive SourceFolderLocation
SourceFile = Application.GetOpenFilename( _
    fileFilter:="Excel Files (*.xls*), *.xls*", MultiSelect:=False)
    
    Workbooks.Open (SourceFile)
    Sheets("CRA_ActCost_PIVOT").Select
    
'This is the template
    Windows("TestFile.xlsx").Activate
    
'Pivot table data that is used
    Range("C28").Select
    ActiveCell.FormulaR1C1 = _
        "=GETPIVOTDATA(""Value"",'[SourceFile]PIVOT'!R3C1,""Team/Branch"",""DataPoint"",""Row Descrption"",""DataPoint2"",""Type"",""Transfer"")"

My problem is in the pivot table data used step...
I wanted "[SourceFile]" To indicated the data should be pulled from the file the user selected however my chart is populated with #n/a in these fields.

Thanks!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top