Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Creating Pivot tables by VBA for varying amounts of data

Hi all,

I have to create a number of pivot tables from the same block of data, and
repeat this with new data four weeks later etc. Data is always in the range
("A3:V" & x) where x varies each 4 weeks.
I have successfully in the past substituted "selection" for the R1C1 range
created in a recorded macro for

'ActiveWorkbook.PivotCaches.Add(SourceType:=xlData base,
SourceData:=Selection)'

but this is now coming up with a "type mismatch" error.
If anyone has any ideas I would be very grateful. I am using Office XP.

TIA

Paul

--
Paul at preeve dot plus dot com


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Creating Pivot tables by VBA for varying amounts of data

Dim rng as Range
With Worksheets("Data")
set rng = .Range(.Cells(3,1),.Cells(rows.count,1).End(xlup))
End with
set rng = rng.Resize(,22)
ActiveWorkbook.PivotCaches.Add( _
SourceType:=xlDatabase, _
SourceData:=rng.Address(1,1,xlR1C1,True)

--
Regards,
Tom Ogilvy


"Paul" wrote in message
...
Hi all,

I have to create a number of pivot tables from the same block of data, and
repeat this with new data four weeks later etc. Data is always in the
range ("A3:V" & x) where x varies each 4 weeks.
I have successfully in the past substituted "selection" for the R1C1 range
created in a recorded macro for

'ActiveWorkbook.PivotCaches.Add(SourceType:=xlData base,
SourceData:=Selection)'

but this is now coming up with a "type mismatch" error.
If anyone has any ideas I would be very grateful. I am using Office XP.

TIA

Paul

--
Paul at preeve dot plus dot com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Creating Pivot tables by VBA for varying amounts of data

thanks Tom, I'll try that in the office tomorrow

Paul

--
Paul at preeve dot plus dot com
"Tom Ogilvy" wrote in message
...
Dim rng as Range
With Worksheets("Data")
set rng = .Range(.Cells(3,1),.Cells(rows.count,1).End(xlup))
End with
set rng = rng.Resize(,22)
ActiveWorkbook.PivotCaches.Add( _
SourceType:=xlDatabase, _
SourceData:=rng.Address(1,1,xlR1C1,True)

--
Regards,
Tom Ogilvy


"Paul" wrote in message
...
Hi all,

I have to create a number of pivot tables from the same block of data,
and repeat this with new data four weeks later etc. Data is always in the
range ("A3:V" & x) where x varies each 4 weeks.
I have successfully in the past substituted "selection" for the R1C1
range created in a recorded macro for

'ActiveWorkbook.PivotCaches.Add(SourceType:=xlData base,
SourceData:=Selection)'

but this is now coming up with a "type mismatch" error.
If anyone has any ideas I would be very grateful. I am using Office XP.

TIA

Paul

--
Paul at preeve dot plus dot com





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Creating Pivot tables by VBA for varying amounts of data

....and it worked fine. Thanks again

--
Paul at preeve dot plus dot com
"Paul" wrote in message
...
thanks Tom, I'll try that in the office tomorrow

Paul

--
Paul at preeve dot plus dot com
"Tom Ogilvy" wrote in message
...
Dim rng as Range
With Worksheets("Data")
set rng = .Range(.Cells(3,1),.Cells(rows.count,1).End(xlup))
End with
set rng = rng.Resize(,22)
ActiveWorkbook.PivotCaches.Add( _
SourceType:=xlDatabase, _
SourceData:=rng.Address(1,1,xlR1C1,True)

--
Regards,
Tom Ogilvy


"Paul" wrote in message
...
Hi all,

I have to create a number of pivot tables from the same block of data,
and repeat this with new data four weeks later etc. Data is always in
the range ("A3:V" & x) where x varies each 4 weeks.
I have successfully in the past substituted "selection" for the R1C1
range created in a recorded macro for

'ActiveWorkbook.PivotCaches.Add(SourceType:=xlData base,
SourceData:=Selection)'

but this is now coming up with a "type mismatch" error.
If anyone has any ideas I would be very grateful. I am using Office XP.

TIA

Paul

--
Paul at preeve dot plus dot com







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a chart with varying data value ranges Anthony Blackburn Excel Discussion (Misc queries) 1 May 17th 10 05:41 PM
creating a pivot table from 4 pivot tables phyllis W Excel Worksheet Functions 0 October 12th 08 09:52 PM
Creating Pivot Tables Andrew Excel Discussion (Misc queries) 0 January 31st 08 10:03 PM
compare data from two tables with varying record numbers british521 Excel Worksheet Functions 0 January 30th 08 08:01 PM
Remove varying amounts of space characters Access Joe Excel Discussion (Misc queries) 4 January 13th 06 10:28 PM


All times are GMT +1. The time now is 02:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"