View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
[email protected] beancurdjelly2003@yahoo.com.hk is offline
external usenet poster
 
Posts: 35
Default macro on pivot tables / pivot items

On 5$B7n(B5$BF|(B, $B2<8a(B10$B;~(B37$BJ,(B, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Try this one...

HTH,
Bernie
MS Excel MVP

Sub SavePTMacro()
Dim i As Integer
Dim j As Integer
Dim myB As Workbook

With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Name")
For i = 1 To .PivotItems.Count
.PivotItems(i).Visible = True
For j = 1 To .PivotItems.Count
If j < i Then .PivotItems(j).Visible = False
Next j
ActiveSheet.Cells.Copy
Set myB = Workbooks.Add
myB.Sheets(1).Cells.PasteSpecial xlPasteValues
myB.SaveAs ThisWorkbook.Path & "\" & .PivotItems(i).Name & ".xls"
MsgBox .PivotItems(i).Name & " has been saved to a new file"
myB.Close
Next i
End With
End Sub

wrote in message

...



Hi,


If I want to save as file instead of print out? How can I do it?


Thanks!- $Bp,i6Ho0zMQJ8;z(B -


- $Bp}<(Ho0zMQJ8;z(B -

Thanks Bernie. It work, but only save one file then show run time
error 1004....

How can same format on Pivottable1 (color, font... ...) when split out
the pivot item?