Access Beginner
Active Member
- Joined
- Nov 8, 2010
- Messages
- 311
- Office Version
- 2016
- Platform
- Windows
Hi All,
Below is code that will copy data from a CSV file called "Data Export" into an Excel file called "Report Template.xlsm". This works fine, the problem I'm having is that I've created a couple of pivot tables, based on this data, and it is group by month and years in the pivot tables. When the data is imported the grouping is lost. The sheet where the Pivot Table is, is called "Content Type" , the pivot table name is "PivotTable1" and the field is called "Date of Activity". The "Date of Activity" field is in the filter of the pivot table
Is there code that can be run that will group the "Date of Activity" field into years and months
Below is code that will copy data from a CSV file called "Data Export" into an Excel file called "Report Template.xlsm". This works fine, the problem I'm having is that I've created a couple of pivot tables, based on this data, and it is group by month and years in the pivot tables. When the data is imported the grouping is lost. The sheet where the Pivot Table is, is called "Content Type" , the pivot table name is "PivotTable1" and the field is called "Date of Activity". The "Date of Activity" field is in the filter of the pivot table
Is there code that can be run that will group the "Date of Activity" field into years and months
Code:
Sub CopyfromDataII()
'Clear existing data
Sheets("ISR Output by Zone").Select
Range("A1:LLL100000").Select
Selection.ClearContents
Range("A1").Select
Dim ToSheet As Worksheet
Dim FromBook As String
Dim ExportFile As Variant
'Path where the Exported data is stored on the Create Zone Reports sheet in cell R37
Set ExportFile = Sheets("Create Zone Reports").Range("r37")
Set ToSheet = ActiveSheet
FromBook = ExportFile
Workbooks.Open FromBook
Cells.Select
Selection.Copy
Windows("ISR Template Post July 2014c.xlsm").Activate
Sheets("ISR Output by Zone").Select
Range("A1").Select
ActiveSheet.Paste
Selection.RowHeight = 15
Range("A1").Select
ThisWorkbook.Save
End Sub