Results 1 to 3 of 3

Name Sheet for a pivot Table

Threaded View

  1. #1
    Registered User
    Join Date
    05-11-2009
    Location
    Iasi, Romania
    MS-Off Ver
    Excel 2003
    Posts
    3

    Post Name Sheet for a pivot Table

    Hy!
    I need some help a with this macro.
    This code is creating successfully a pivot table in a sheet called "SheetY" where Y is the next number available for sheets .
    Can anyone tell me how can i pinpoint a fixed destination for the pivottable (eg : "new_sheet").
    Running the macro several times will create Sheet4,5,6,7,8 etc.
    Sub CreatePiovot()
    Dim strHead As String
    Dim strSheetName As String
    Dim strListAddress As String
    
        
        strHead = Selection.Cells(1, 1)
        strSheetName = "'" & ActiveSheet.Name & "'!"
    
    
        strListAddress = Selection.Address(ReferenceStyle:=xlR1C1)
      
       ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _ SourceData:=  strSheetName & _
    strListAddress).CreatePivotTable TableDestination:="", TableName:="pivot"
     
         ActiveSheet.PivotTables("pivot").AddFields RowFields:=strHead
    
            With ActiveSheet.PivotTables("pivot").PivotFields(strHead)
        .Orientation = xlDataField
        .Caption = "Results"
        .Function = xlCount
    
            End With
            
            ActiveWorkbook.ShowPivotTableFieldList = False
    
            Application.CommandBars("PivotTable").Visible = False
    
        
    
    End Sub
    Have a nice day !
    Last edited by stefannel; 05-12-2009 at 03:48 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1