Notices
Non Scooby Related Anything Non-Scooby related

Microsoft Excel

Thread Tools
 
Search this Thread
 
Old Feb 5, 2002 | 12:09 PM
  #1  
MattN's Avatar
MattN
Thread Starter
Scooby Regular
 
Joined: Nov 2000
Posts: 2,174
Likes: 0
Post

Pivot Tables.

Does anyone know how to select the whole pivot table in VBA.

I want a macro that creates a pivot table then copies it, but I'm having real problems selecting the whole thing.

Anyone?????
Reply
Old Feb 5, 2002 | 12:23 PM
  #2  
fast bloke's Avatar
fast bloke
Scooby Regular
 
Joined: Nov 2000
Posts: 26,619
Likes: 0
Question

Can you not se the Macro recorder to get the code?
Reply
Old Feb 5, 2002 | 12:29 PM
  #3  
MattN's Avatar
MattN
Thread Starter
Scooby Regular
 
Joined: Nov 2000
Posts: 2,174
Likes: 0
Post

nope, doesn't like it,

this is what I have so far -

Dim mypivot As PivotTable
Dim myfield As PivotField
Dim myitem As PivotItem
Dim myrange As Range

Set mypivot = ActiveSheet.PivotTableWizard
Set myfield = mypivot.PivotFields("T1-Gross-Qty")
myfield.Orientation = xlDataField
Set myfield = mypivot.PivotFields("ISBN")
myfield.Orientation = xlRowField
mypivot.AddFields "ISBN", "Rep-Area"


****now in here I want to select the whole table*****
Reply
Old Feb 5, 2002 | 12:48 PM
  #4  
Martingb's Avatar
Martingb
Scooby Regular
 
Joined: Oct 2001
Posts: 65
Likes: 0
Post

Use code to select a cell within the pivot table and then use the current region command

e.g.
range("a1").select
Selection.CurrentRegion.Select

Martin.
Reply
Old Feb 5, 2002 | 12:55 PM
  #5  
fast bloke's Avatar
fast bloke
Scooby Regular
 
Joined: Nov 2000
Posts: 26,619
Likes: 0
Post

Range("range of pivot table").Select
Selection.Copy
Range("top left corner of where you want to put it").Select
ActiveSheet.Paste



Just tried this and it works for me. Also updates new table on a refresh, so it is actually copying the table and not simply the contents
Reply
Old Feb 5, 2002 | 12:57 PM
  #6  
fast bloke's Avatar
fast bloke
Scooby Regular
 
Joined: Nov 2000
Posts: 26,619
Likes: 0
Post

p.s. for the range of pivot table, use A1:B3 format, specifying top left and bottom right corners
Reply
Old Feb 5, 2002 | 04:49 PM
  #7  
MattN's Avatar
MattN
Thread Starter
Scooby Regular
 
Joined: Nov 2000
Posts: 2,174
Likes: 0
Post

cheers Martin.

FB, the problem with selecting the range is the pivot tables in this macro are all different sizes and when new ones are created are different sizes again, meaning I couldn't just selct a range.

Cheers guys
Reply
Old Feb 5, 2002 | 05:01 PM
  #8  
fast bloke's Avatar
fast bloke
Scooby Regular
 
Joined: Nov 2000
Posts: 26,619
Likes: 0
Talking

I thought it was too easy
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
Dec 28, 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
Nov 18, 2015 07:03 AM
leg200
Subaru Parts
5
Oct 7, 2015 07:31 AM
has-scooby
Subaru Parts
4
Oct 6, 2015 03:47 PM
bluebullet29
General Technical
9
Oct 5, 2015 02:17 PM




All times are GMT +1. The time now is 12:00 AM.