Creating PivotTable from CVS File

Hashiru

Active Member
Joined
May 29, 2011
Messages
286
Hi all I have the below code. It is using MS Access data source , I want to change it to csv file as the file will now be csv rather than MS Access. Can you help me change the line of codes to do the trick. I am expecting the underline lines of code but will appreciate any change.

Thanks in advance to all.

Sub Report() Dim WS As Woksheet
Dim WB As Workbook

Set WB = ThisWorkbook
Set WS = WB.Worksheets("Report")
Application.ScreenUpdating = False
WS.Cells.Clear
Workbooks(ThisWorkbook.Name).Connections.Add2 _
"DbFile", "", Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=C:\Users\C033732\Desktop\Report Templates\Dennis Report" _
, _
"DbFile.accdb;Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path=" _
, _
""""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;" _
, _
"Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt" _
, _
" Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;" _
, _
"Jet OLEDB:Support Complex Data=False;Jet OLEDB:Bypass UserInfo Validation=False;Jet OLEDB:Limited DB Caching=False;Jet OLEDB:Byp" _
, "*** ChoiceField Validation=False"), "SourceTable", 3

Dim PC As PivotCache
Dim PT As PivotTable
Dim PTn As PivotTable
WS.Activate
'Delete Prior PivotTable
Set PC = WB.PivotCaches.Create(SourceType:=xlExternal, SourceData:=WB.Connections("DbFile"), Version:=6)
Set PT = PC.CreatePivotTable(TableDestination:="Report!R3C1", TableName:="xLabor", DefaultVersion:=6)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

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