Hi Roger,
I have tried that as well.
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase,
SourceData:= _
rng, Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="4x4!R3C1", TableName:="PivotTable2",
DefaultVersion _
:=xlPivotTableVersion12
I am still facing an error. It is now Run time Error 13 - "Type
mismatch"
Webbug
On Apr 29, 10:37 pm, Roger Govier <[email protected]> wrote:
> Hi
>
> I think the problem is that you are enclosing rng within quotes as your
> Source data.
> Try removing the quotes and it should work.
> ActiveWorkbook.PivotCaches.
>
>
>
> > Create(SourceType:=xlDatabase, SourceData:= rng,
>
> Regards
>
> Roger Govier
> Microsoft Excel MVP
>
> 2009/4/29 Govind Kedia <[email protected]>
>
>
>
>
>
>
>
> > I am trying to create a pivot table on a new sheet names as 4x4
>
> > I am getting following error:
> > Error : 1004
> > Reference Not Valid
>
> > I am not sure where is the problem. I have genererated this code by
> > using macro recorder and just changed the source and destination of
> > the pivot generation code.
>
> > Need your help Guys!!!
>
> > Sub Macro2()
> > ActiveWorkbook.Sheets("Sheet2").Activate
> > Dim LastRow1 As Long
> > With ActiveSheet
> > LastRow1 = Sheets("Sheet2").Cells(.Rows.Count, "A").End(xlUp).Row
> > End With
> > Dim rng As Range
>
> > Set rng = Range(Cells(1, 1), Cells(LastRow1, 19))
>
> > Sheets.Add.Name = "4x4"
>
> > ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase,
> > SourceData:= _
> > "rng", Version:=xlPivotTableVersion12).CreatePivotTable _
> > TableDestination:="4x4!R3C1", TableName:="PivotTable2",
> > DefaultVersion _
> > :=xlPivotTableVersion12
> > Sheets("4x4").Select
> > Cells(3, 1).Select
>
> > Also Tried this one
>
> > ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase,
> > SourceData:= _
> > rng, Version:=xlPivotTableVersion12).CreatePivotTable _
> > TableDestination:="4x4!R3C1", TableName:="PivotTable2",
> > DefaultVersion _
> > :=xlPivotTableVersion12
>
> > I am still facing an error. It is now Run time Error 13 - "Type
> > mismatch"
>
> > I am using following code now
>
> --
> Roger Govier
> [email protected] Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
To post to this group, send email to [email protected]
If you find any spam message in the group, please send an email to:
Ayush Jain @ [email protected] or
Ashish Jain @ [email protected]
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---