Hi All;
First time poster, long time lurker... this place has taught me more about VBA than any book, which is why I am hoping you can help me!
I have created a spreadsheet which uses 4 external sets of data to build 4 different pivot tables. These can be updated manually (obviously) with no issue, but the spreadsheet is for people whose Excel knowledge is less than proficient, and who I would not trust to update them correctly.
So, I thought I could type the address of the data into Excel, Name that cell in VBA, and then tell the Macro to source the data from that file... so all they would have to do is change the file name every month, and everything would be okay.
That is what I have come up with so far... however, when I try and run this Macro, it comes up with the following
So, my issue, mainly, seems to be that I just need it to specify Sheet 1 to look at, rather than make it part of the File Name. Everything else will be fine then... can you help?
First time poster, long time lurker... this place has taught me more about VBA than any book, which is why I am hoping you can help me!
I have created a spreadsheet which uses 4 external sets of data to build 4 different pivot tables. These can be updated manually (obviously) with no issue, but the spreadsheet is for people whose Excel knowledge is less than proficient, and who I would not trust to update them correctly.
So, I thought I could type the address of the data into Excel, Name that cell in VBA, and then tell the Macro to source the data from that file... so all they would have to do is change the file name every month, and everything would be okay.
MONTHP = Sheets("Front Sheet").Range("B10").Value
CQUARTER = Sheets("Front Sheet").Range("B11").Value
NQUARTER = Sheets("Front Sheet").Range("B12").Value
FULLYEAR = Sheets("Front Sheet").Range("B12").Value
'
Application.ScreenUpdating = False
Sheets("Pivot Data").Visible = True
Sheets("Pivot Data").Select
Range("A2").Select
ActiveSheet.PivotTables("PivotTable2").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
MONTHP & "Sheet1!R1C1:R10000C83", Version:=xlPivotTableVersion12)
That is what I have come up with so far... however, when I try and run this Macro, it comes up with the following
Run-time error '-2147024809 (80070057)';
Cannot open PivotTable source file '\\pdataserv\userdata\D and A\COMMERCIAL REVIEW\FINANCE\FY12\F03\PIVOT DATA\ACT_COMREV_JUNE MTH_FINAL.xlsSheet1'.
So, my issue, mainly, seems to be that I just need it to specify Sheet 1 to look at, rather than make it part of the File Name. Everything else will be fine then... can you help?