balaji3081
Member
Hi,
Below is the Macro I run - To create a copy of the base file and to get the required data and deleting the rest, and refreshing the pivots, this work really great, thaks to debraj (excel Ninja).
Coming to the point - the new file created has three pivots , and the range it has is of the base file and not of the own file.....
Sub GetData()
With Sheets(1)
ParentDept = Left(.[G3], 4): dept = Left(.[G5], 4)
' fname = "\" & .[c3] & " - " & .[c5] & " - " & _
' MonthName(Format(Date, "m") - 1, True)
End With
Sheets.Copy
Set deb = ActiveWorkbook
With deb
For i = Sheets.Count To 2 Step -1
With Sheets(i)
Select Case .Name
Case "RDW - Actuals", "BUDGET - FY13-FPA", "FTE", "RDW LY Actuals"
Sheets(i).Select
Set hdr = .UsedRange.Find(What:="SUB- DEPT", LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
With .UsedRange.Offset(1)
If Not Sheets(i).AutoFilterMode Then _
.AutoFilter
.Value = .Value
.AutoFilter hdr.Column, "="
.Offset(1).SpecialCells(12).EntireRow.Delete -4162
.AutoFilter
End With
End Select
End With
Next i
Sheets("Details").PivotTables("PivotTable6").RefreshTable
Sheets("FMNO Driven Expenses").PivotTables("PivotTable1").RefreshTable
Sheets("Project Driven Expenses").PivotTables("PivotTable2").RefreshTable
End With
MsgBox "File Ready! Please save.. "
End Sub
Below is the Macro I run - To create a copy of the base file and to get the required data and deleting the rest, and refreshing the pivots, this work really great, thaks to debraj (excel Ninja).
Coming to the point - the new file created has three pivots , and the range it has is of the base file and not of the own file.....
Sub GetData()
With Sheets(1)
ParentDept = Left(.[G3], 4): dept = Left(.[G5], 4)
' fname = "\" & .[c3] & " - " & .[c5] & " - " & _
' MonthName(Format(Date, "m") - 1, True)
End With
Sheets.Copy
Set deb = ActiveWorkbook
With deb
For i = Sheets.Count To 2 Step -1
With Sheets(i)
Select Case .Name
Case "RDW - Actuals", "BUDGET - FY13-FPA", "FTE", "RDW LY Actuals"
Sheets(i).Select
Set hdr = .UsedRange.Find(What:="SUB- DEPT", LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
With .UsedRange.Offset(1)
If Not Sheets(i).AutoFilterMode Then _
.AutoFilter
.Value = .Value
.AutoFilter hdr.Column, "="
.Offset(1).SpecialCells(12).EntireRow.Delete -4162
.AutoFilter
End With
End Select
End With
Next i
Sheets("Details").PivotTables("PivotTable6").RefreshTable
Sheets("FMNO Driven Expenses").PivotTables("PivotTable1").RefreshTable
Sheets("Project Driven Expenses").PivotTables("PivotTable2").RefreshTable
End With
MsgBox "File Ready! Please save.. "
End Sub