I am having problems with a pivot table that uses an external .csv file as the source, especially with dates in the csv file being processed as text. So, I decided to import the csv file into another worksheet, and then force the dates to be recognized as such by reformatting the corresponding columns.
Now the problem is to modify the existing pivot table to use data on a new sheet instead of an external source. If I click the Change Data Source button, the Select Table or Range option will be grayed out. If I continue with the external data source and click the "Select Connection" button and select a new worksheet, I will get a pop-up message that says: "The type of the selected connection cannot be used to create a pivot table."
I also tried converting the csv file to xlsx, but had a similar problem trying to force the existing pivot table to use it instead of csv as the source.
, .
.csv .xls :
VBA :
Sub getExcelData() With ActiveSheet.PivotTables("PivotTable1").PivotCache .Connection = Array( _ Array("ODBC;DSN=Excel Files;"), _ Array("DBQ=c:\path\to\datasource.xls;"), _ Array("DefaultDir=c:\path\to;DriverId=790;MaxBufferSize=2048;PageTimeout=5;") _ ) .CommandText = _ "SELECT `Data$`.Birthdate, `Data$`.Name, `Data$`.Sign" & vbCrLf & _ "FROM `c:\path\to\datasource.xls`.`Data$` `Data$`" End With End Sub
.CommandText .
YMMV 2010 / . , , Excel. , , , .
, , , . , VBA . , .
, , , , .
, , , , Visual Basic Macro Ctrl + G, . mendosi. , , , . , VBA . , .
( ). . "? Selection.pivottable.cacheindex" enter. . Excel , . "selection.pivottable.cacheindex = x", x - , 4. 6 , . , 1. , , , , .
, . , , , .
Excel 2010:
, ,
Thanks a lot, Ines. (I donβt know why someone voted for you).
Have you tried opening the rotation wizard and returning to step 1 (where are the data that you want to analyze)? In excel 2007, the shortcut to open the wizard is alt + d + p (or you can hover a button on it in the quick access toolbar). Hope this helps.