+ Reply to Thread
Results 1 to 1 of 1

VBA Pivot Code

  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    Austin, TX
    MS-Off Ver
    Excel 2007
    Posts
    84

    VBA Pivot Code

    Hi,
    I'm trying to get my vba code to select a variable length of rows. However, I think I formatted it wrong, because it returns nothings. I am still researching the issue. Below is my code and attached to this thread is my workbook.

    The macro is title Pivot_Relative

    Thanks for your help.

    Sub Pivot_relative()
    On Error Resume Next
    ThisWorkbook.Worksheets("Output").Delete
    Sheets.Add.Name = "Output"


    Dim wk1 As Worksheet
    Set wk1 = ThisWorkbook.Worksheets("Source")
    Set FinalRow = ThisWorkbook.Worksheets("Source").Cells(Rows.Count, 1).End(xlUp).Row
    Dim wk2 As Worksheet
    Set wk2 = ThisWorkbook.Worksheets("Output")


    ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    wk1 & "R4C2:R" & FinalRow & "C4", Version:=xlPivotTableVersion15).CreatePivotTable _
    TableDestination:="Output!R3C1", TableName:="PivotTable1", DefaultVersion _
    :=xlPivotTableVersion15
    Sheets(wk2).Select
    Cells(3, 1).Select
    With wk2.PivotTables("PivotTable1").PivotFields("Name")
    .Orientation = xlRowField
    .Position = 1
    End With


    End Sub
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need a VB Code for Pivot Table instead of using custom format code
    By Linus100 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-02-2014, 01:13 PM
  2. VBA code to update pivot to "blank" if item in not found in pivot filter
    By misslady11 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2014, 11:36 PM
  3. VBA Code for pivot countif
    By tanfeicici in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-05-2013, 09:33 PM
  4. code a pivot table?
    By shacan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2011, 11:55 AM
  5. VBA Code which mirrors changes on one pivot onto a second pivot
    By Stepheny2k2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2010, 07:18 AM

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