First off, I want to specify that I have very little to no knowledge of VBA.
What I have put together is a mere step by step copy and paste code.
I am just trying to simplify my code from have over 1000 lines of code down to as few as possible, but still have the same outcome.
I have a excel file that is pulling data from 2 different files, to make a specialized report.
I am unable to share the file, as the data in extremely sensitive, but I will try to explain as detailed as possible.
The file that is being opened has a pivot table on the sheet that is first displayed. The code will then change a few things on the pivot table that do not need to be displayed. It will then "show details" on the first row of the values. Copy the data from that table, into a specific sheet, and repeat. The data will be pasted at the bottom of the previous paste until there are no more rows/values to "show details".
Any help will be greatly appreciated.
Thank in advance.
What I have put together is a mere step by step copy and paste code.
I am just trying to simplify my code from have over 1000 lines of code down to as few as possible, but still have the same outcome.
I have a excel file that is pulling data from 2 different files, to make a specialized report.
I am unable to share the file, as the data in extremely sensitive, but I will try to explain as detailed as possible.
The file that is being opened has a pivot table on the sheet that is first displayed. The code will then change a few things on the pivot table that do not need to be displayed. It will then "show details" on the first row of the values. Copy the data from that table, into a specific sheet, and repeat. The data will be pasted at the bottom of the previous paste until there are no more rows/values to "show details".
Any help will be greatly appreciated.
Thank in advance.
Code:
Sub GetData()
'
' GetData Macro
' Get Data
'
'
Sheets("FileList").Select
PathName = Range("J5").Value
Filename = Range("J3").Value
Application.DisplayAlerts = False
Workbooks.Open Filename:=PathName & Filename, _
Notify:=False
ActiveSheet.PivotTables("PivotTable2").PivotFields("ReportDate").CurrentPage = _
"(All)"
ActiveSheet.PivotTables("PivotTable2").PivotFields("ReportDate"). _
EnableMultiplePageItems = True
ActiveSheet.PivotTables("PivotTable2").PivotFields("SrTM").Orientation = _
xlHidden
ActiveSheet.PivotTables("PivotTable2").PivotFields("TM").Orientation = xlHidden
With ActiveSheet.PivotTables("PivotTable2")
.ColumnGrand = False
.RowGrand = False
End With
Range("C4").Select
Selection.ShowDetail = True
Range("A2:S2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Testing.xlsx").Activate
Sheets("RawData").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Windows("Shrink.xlsx").Activate
ActiveWindow.SelectedSheets.Delete
Range("C5").Select
Selection.ShowDetail = True
Range("A2:S2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Testing.xlsx").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Windows("Shrink.xlsx").Activate
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
End Sub