+ Reply to Thread
Results 1 to 2 of 2

Pivot Table in VB

  1. #1
    Alastair79
    Guest

    Pivot Table in VB

    I have a macro that changes an EDI file into a nice four column table, this
    table changes in length according to the orders. So I do the following to
    highlight all the data:

    ActiveCell.Offset(1, 0).Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select

    I then want to create a pivot table from the highlighted data. I recorded
    myself doing this but as you can see it's given me a deffinate range of cells
    instead of calling the highlighted cells:

    ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    "Data!R2C1:R479C4").CreatePivotTable TableDestination:=ActiveCell.Offset(0,
    4) _
    ..Range("A1"), TableName:="PivotTable1"

    Is there anyway around this? Thanks......... Alastair.

  2. #2
    Registered User
    Join Date
    04-21-2006
    Posts
    61
    Hi,
    Assuming you have nothing above or below the data you want to include, I have used the entire Columns in my ranges before... this works fine, and has the advantage of including any more data you add. Just replace the RxCx bits with $D:$G or whatever the columns are...

    hope this helps
    gareth

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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