Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Type Mismatch when creating a pivottable macro

Hi,

I've been searching through this group for similar problems (and found
one) but I was still unable to resolve the issue below. When I try to
set bigcache, it throws a type mismatch at me and I'll be damned if I
can work it out. Any help is much appreciated. My code is:



Function consolidateData()

Dim varArray(3) As Variant
Dim headingNames As New Collection
Dim bigcache As Variant


headingNames.Add "Item1"
headingNames.Add "Item2"
headingNames.Add "Item3"

For i = 2 To Sheets.Count - 1
varArray(i) = Array(Sheets(i). _
Range("A1").CurrentRegion.Address(external:=True,
ReferenceStyle:=xlR1C1), _
headingNames(i - 1))
Next


Set bigcache = ActiveWorkbook.PivotCaches.Add( _
SourceType:=xlConsolidation, _
SourceData:=varArray)

bigcache.CreatePivotTable _
TableDestination:="", TableName:="PivotTable3",
DefaultVersion:= _
xlPivotTableVersion13
ActiveSheet.PivotTableWizard
TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").DataPivotFi eld.PivotItems(
_
"Count of Value").Position = 1
ActiveWorkbook.ShowPivotTableFieldList = True
End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Type Mismatch when creating a pivottable macro


I've been searching through this group for similar problems (and found
one) but I was still unable to resolve the issue below. When I try to
set bigcache, it throws a type mismatch at me and I'll be damned if I
can work it out. Any help is much appreciated. My code is:


<snip
Dim bigcache As Variant


Have you tried making bigcache a PivotCache instead of a Variant?

Iain King


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
Error type mismatch in writing macro ub Excel Worksheet Functions 2 September 26th 07 12:48 PM
Macro error type mismatch Jurassien Excel Discussion (Misc queries) 3 February 23rd 07 08:14 PM
Visual Basic macro run time error(13) type mismatch Paul Excel Discussion (Misc queries) 0 October 25th 05 07:28 AM
Creating a database and PivotTable with a Macro sales26 Excel Programming 2 May 19th 04 05:05 PM
Type mismatch Alan Beban[_4_] Excel Programming 0 February 4th 04 08:39 PM


All times are GMT +1. The time now is 04:53 PM.

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"