Hi Vikash,
try something like..
Code:
Option Explicit
Sub kTest()
Dim TeamName As String
Dim EmpName As String
Dim FName As String
Dim ShtInput As Worksheet
Dim Pvt As PivotTable
Set Pvt = Worksheets("Pivot 1").PivotTables("PivotTable3")
Set ShtInput = Worksheets("Input Sheet")
TeamName = ShtInput.Range("c5").Value
EmpName = ShtInput.Range("c6").Value
FName = ShtInput.Range("c7").Value & ".pdf"
With Pvt
.PivotFields("Team").ClearAllFilters
.PivotFields("Team").CurrentPage = TeamName
CreatePDF .TableRange1, FName 'replace .TableRange1 with .TableRange2 if you need team name as well
End With
End Sub
Sub CreatePDF(ByRef Range2Print As Range, Optional PDFFileName As String)
If Len(PDFFileName) = 0 Then
PDFFileName = ThisWorkbook.Path & "\Test.pdf"
End If
Range2Print.ExportAsFixedFormat Type:=xlTypePDF, FileName:=PDFFileName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
Bookmarks