Notices
Non Scooby Related Anything Non-Scooby related

Microsoft Excel

Thread Tools
 
Search this Thread
 
Old 05 February 2002, 12:09 PM
  #1  
MattN
Scooby Regular
Thread Starter
 
MattN's Avatar
 
Join Date: Nov 2000
Posts: 2,174
Likes: 0
Received 0 Likes on 0 Posts
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?????
Old 05 February 2002, 12:23 PM
  #2  
fast bloke
Scooby Regular
 
fast bloke's Avatar
 
Join Date: Nov 2000
Posts: 26,619
Likes: 0
Received 0 Likes on 0 Posts
Question

Can you not se the Macro recorder to get the code?
Old 05 February 2002, 12:29 PM
  #3  
MattN
Scooby Regular
Thread Starter
 
MattN's Avatar
 
Join Date: Nov 2000
Posts: 2,174
Likes: 0
Received 0 Likes on 0 Posts
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*****
Old 05 February 2002, 12:48 PM
  #4  
Martingb
Scooby Regular
 
Martingb's Avatar
 
Join Date: Oct 2001
Posts: 65
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 05 February 2002, 12:55 PM
  #5  
fast bloke
Scooby Regular
 
fast bloke's Avatar
 
Join Date: Nov 2000
Posts: 26,619
Likes: 0
Received 0 Likes on 0 Posts
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
Old 05 February 2002, 12:57 PM
  #6  
fast bloke
Scooby Regular
 
fast bloke's Avatar
 
Join Date: Nov 2000
Posts: 26,619
Likes: 0
Received 0 Likes on 0 Posts
Post

p.s. for the range of pivot table, use A1:B3 format, specifying top left and bottom right corners
Old 05 February 2002, 04:49 PM
  #7  
MattN
Scooby Regular
Thread Starter
 
MattN's Avatar
 
Join Date: Nov 2000
Posts: 2,174
Likes: 0
Received 0 Likes on 0 Posts
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
Old 05 February 2002, 05:01 PM
  #8  
fast bloke
Scooby Regular
 
fast bloke's Avatar
 
Join Date: Nov 2000
Posts: 26,619
Likes: 0
Received 0 Likes on 0 Posts
Talking

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



Quick Reply: Microsoft Excel



All times are GMT +1. The time now is 08:00 PM.