'The following code segment works
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = Array( _
"OLEDB; Provider=MSOLAP; Initial Catalog=[OCWCube]; Data Source= " + Range("A1"

+ ";" _
, _
"
CreateCube=CREATE CUBE [OCWCube] ( DIMENSION [F6], LEVEL [All] TYPE ALL, LEVEL [F6], DIMENS" _
, _
"ION [F5], LEVEL [All] TYPE ALL, LEVEL [F5], DIMENSION [F4], LEVEL [All] TYPE ALL, LEVEL [F4], DIMENSION [F3], " _
, _
" LEVEL [All] TYPE ALL, LEVEL [F3], MEASURE [Count Of F1] FUNCTION COUNT, MEASURE [Count Of F2] FUNCTION COUNT ); " _
, _
"InsertInto=INSERT INTO OCWCube([Count Of F1], [Count Of F2], [F3].[F3], [F4].[F4], [F5].[F5], [F6].[F6]) OPTIONS ATTEMPT_ANALYS" _
, _
"IS SELECT file1.F1, file1.F2, file1.F3, file1.F4, file1.F5, file1.F6 FROM file1.txt file1; Source_DSN=""DefaultDir=C:\Document" _
, _
"s and Settings\directory\My Documents;Driver={Microsoft Text Driver (*.txt; *.csv)};DriverId=27;FIL=text;MaxBufferSize=2048;MaxSc" _
, _
"anRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"";UseExistingFile=False" _
)
.CommandType = xlCmdCube
.CommandText = Array("OCWCube"

.MaintainConnection = True
.CreatePivotTable TableDestination:="", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
End With
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
I have not been able to correctly replace the CreateCube argument with a variable (CubeDimension) holding the same string
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = Array( _
"OLEDB; Provider=MSOLAP; Initial Catalog=[OCWCube]; Data Source= " + Range("A1"

+ ";" _
, _
"
CreateCube= " + CubeDimension + "; " _
, _
"InsertInto=INSERT INTO OCWCube([Count Of F1], [Count Of F2], [F3].[F3], [F4].[F4], [F5].[F5], [F6].[F6]) OPTIONS ATTEMPT_ANALYS" _
, _
"IS SELECT file1.F1, file1.F2, file1.F3, file1.F4, file1.F5, file1.F6 FROM file1.txt file1; Source_DSN=""DefaultDir=C:\Document" _
, _
"s and Settings\directory\My Documents;Driver={Microsoft Text Driver (*.txt; *.csv)};DriverId=27;FIL=text;MaxBufferSize=2048;MaxSc" _
, _
"anRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"";UseExistingFile=False" _
)
.CommandType = xlCmdCube
.CommandText = Array("OCWCube"

.MaintainConnection = True
.CreatePivotTable TableDestination:="", TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
End With
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
I've tried this with the CubeDimension variable both as a variant and as a string as well as putting it in a cell and using a "Range" reference, with and without the " + + " syntax and I've tried leaving the "CREATE CUBE [OCWCube] " part in the argument and just setting CubeDimension to the parenthetical statement. Let me know if more code or more cleaned up code would be helpful. (Sorry about the mess and thank you for any help)