with below code when you double click on any values in pivot table
the new workbook will be created & save in the same folder
the new workbook will be created & save in the same folder
Private Sub Workbook_NewSheet(ByVal Sh As Object)
Dim nwk As String, sPath As String, sFileName As String
Sh.Move
nwk = ActiveWorkbook.Name
Workbooks(nwk).Activate
Workbooks(nwk).ActiveSheet.Name = Cells(2, 1).Value & "_" & Cells(2, 3).Value
Dim nwk As String, sPath As String, sFileName As String
Sh.Move
nwk = ActiveWorkbook.Name
Workbooks(nwk).Activate
Workbooks(nwk).ActiveSheet.Name = Cells(2, 1).Value & "_" & Cells(2, 3).Value
'Save the new workbook
sPath = ThisWorkbook.Path & "\"
sFileName = ActiveSheet.Name
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs (sPath & sFileName)
ActiveWorkbook.Close True
End Sub
sPath = ThisWorkbook.Path & "\"
sFileName = ActiveSheet.Name
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs (sPath & sFileName)
ActiveWorkbook.Close True
End Sub
No comments:
Post a Comment