T
TroyT
Hello,
I have recorded almost what I need and hoped you guys here would be able to
help me. This Macro will
Drill down into 8 specifically placed pivot tables on a single worksheet,
and save the individual files to c:\test.csv
The macro works if every pivot table has data, but if its blank it fails.
Also, i need help in making the file names change. It could be previous +1
or anything as long as there is never a duplicate..
Here is the macro.
Sub getdata()
'
' getdata Macro
'
' Keyboard Shortcut: Ctrl+q
'
Range("C7").Select
Selection.ShowDetail = True
ChDir "C:\test"
ActiveWorkbook.SaveAs Filename:="C:\test\1.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("F7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\2.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("I7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\3.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("L7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\4.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("O7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\5.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("R7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\6.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("U7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\7.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("X7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\8.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
ActiveWindow.Close
End Sub
I have recorded almost what I need and hoped you guys here would be able to
help me. This Macro will
Drill down into 8 specifically placed pivot tables on a single worksheet,
and save the individual files to c:\test.csv
The macro works if every pivot table has data, but if its blank it fails.
Also, i need help in making the file names change. It could be previous +1
or anything as long as there is never a duplicate..
Here is the macro.
Sub getdata()
'
' getdata Macro
'
' Keyboard Shortcut: Ctrl+q
'
Range("C7").Select
Selection.ShowDetail = True
ChDir "C:\test"
ActiveWorkbook.SaveAs Filename:="C:\test\1.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("F7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\2.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("I7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\3.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("L7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\4.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("O7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\5.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("R7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\6.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("U7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\7.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
Range("X7").Select
Selection.ShowDetail = True
ActiveWorkbook.SaveAs Filename:="C:\test\8.csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveSheet.Next.Select
ActiveWindow.Close
End Sub