Run time error 1004

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,130
Getting an error on this..
Run time error 1004
Analysis.xlsx could not be found.

Path is correct.. What it can be, pls guide..
Code:
Range("A4").Select

ActiveSheet.PivotTables("PivotTable2").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:=Pth & "\" & "[ANALYSIS.xlsx]Details!A:AF", Version:=xlPivotTableVersion14)


Sheets("Tie").Select
Range("B4").Select


ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
 

Some videos you may like

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,130
Dear All Board member,

I believe this really simple for you..Can any one expert can respond on this...Really appriciate for help in advance...

Getting an error on this..
Run time error 1004
Analysis.xlsx could not be found.

Path is correct.. What it can be, pls guide..
Code:
Range("A4").Select

ActiveSheet.PivotTables("PivotTable2").ChangePivotCache ActiveWorkbook. _
PivotCaches.Create(SourceType:=xlDatabase, SourceData:=Pth & "\" & "[ANALYSIS.xlsx]Details!A:AF", Version:=xlPivotTableVersion14)


Sheets("Tie").Select
Range("B4").Select


ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
54,443
Office Version
  1. 365
Platform
  1. Windows
That seems to imply that it may not be able find the file. You have posted how "Pth" is calculated, so there isn't much we can do to verify that you have done it correctly.

I would recommend doing this to see what it returns, and verify it is a valid path, file name, and sheet, and range. If you do not see any issue, please post here what this MsgBox returns:
Code:
MsgBox [COLOR=#333333][I]Pth & "\" & "[ANALYSIS.xlsx]Details!A:AF"[/I][/COLOR]
 

Watch MrExcel Video

Forum statistics

Threads
1,108,751
Messages
5,524,621
Members
409,595
Latest member
therevford

This Week's Hot Topics

Top