Results 1 to 20 of 20

Thread: [RESOLVED] Problem with VB Macro in Excel for Pivot Table

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    22

    Resolved [RESOLVED] Problem with VB Macro in Excel for Pivot Table

    Hi

    I am generating a pivot table out of worksheet named: Reporting

    I recorded an excel macro of the steps to produce the pivot table:
    VB Code:
    1. ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
    2.         "Reporting!R1C1:R378C31"
    3.     ActiveSheet.PivotTables("PivotTable3").SmallGrid = False
    4.     ActiveSheet.PivotTables("PivotTable3").AddFields RowFields:=Array("Severity", _
    5.         "Open/Closed"), ColumnFields:="Area"
    Because the range of cells changes I have produced theses variables:

    LastRow
    LastCol

    I am trying to use those in the code above such that:
    VB Code:
    1. LastRow = ":R" & LastRow
    2.  
    3.     ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:=“Reporting!R1C2” & LastRow + “C” + LastCol
    4.     ActiveSheet.PivotTables("PivotTable3").SmallGrid = False
    5.     ActiveSheet.PivotTables("PivotTable3").AddFields RowFields:=Array("Severity", _
    6.         "Open/Closed"), ColumnFields:="Area"
    When in this format the code doesn't work.

    Cheers

    Dave
    Last edited by Hack; Apr 13th, 2006 at 08:38 AM. Reason: Added [vbcode] [/vbcode] tags for more clarity.

Posting Permissions

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



Click Here to Expand Forum to Full Width