Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Pivot Table type mismatch

Well, since no one seemed to have any ideas I did some more work on
this and found a work-around.

These lines are inserted in the appropriate sections of teh code.

myrng="R" & ro & "C" & col

And then;
SourceData:="Received!R1C1:" & myrng

That gives me the flexibility I need and keeps the dreaded error 13 at
bay.

Bill

Bill wrote:
Hi folks,
When I run the following macro I get a type mismatch when it tries to
create the pivot table. The commented out section works but I need to
have the flexibility of using the variables for the bottom-right edge
of the data as that changes daily. The section that gives me the type
mismatch here works exactly as written in another macro. Very confused,
I am.
Thanks,
Bill

Option Explicit
Sub sort_recvd()

Dim ro As Long, col As Long
Dim FileLoc As String

'Where to look for the csv file.
FileLoc = "TEXT;" & Environ("USERPROFILE") & "\Desktop\"

' Import csv file and find its edges.
ActiveWorkbook.Sheets.Add
With ActiveSheet.QueryTables.Add(Connection:= _
FileLoc & "receipts.csv", Destination:=Range("A1"))
.Name = "Received"
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileTabDelimiter = True
.Refresh BackgroundQuery:=False
End With
ActiveSheet.Name = "Received"
ro = Cells(Rows.Count, "A").End(xlUp).Row
col = Cells(1, Columns.Count).End(xlToLeft).Column

' Build pivot table.
'= This section works but locks me into that data range.
' ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
' SourceData:="Received!R1C1:R244C30").CreatePivotTa ble _
' TableDestination:="", TableName:="Received Units"

'= This section gives a type mismatch but works as written in another
macro.
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=ActiveSheet.Range("A1", Cells(ro,
col))).CreatePivotTable _
TableDestination:="", TableName:="Received Units"
With ActiveSheet.PivotTables(1).PivotFields("Return Account")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables(1).PivotFields("Part #")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables(1).AddDataField _
ActiveSheet.PivotTables(1).PivotFields("Promised") , _
"Count of Promised", xlCount

Cells.EntireColumn.AutoFit

End Sub


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
When refreshing pivot tables my pivot table chart type changes hannah220507 Excel Discussion (Misc queries) 1 May 22nd 07 02:57 PM
Type Mismatch: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Pivot Tables Formatting interior color &Type Mismatch CraigS Excel Programming 0 January 8th 05 07:45 PM


All times are GMT +1. The time now is 05:33 AM.

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

About Us

"It's about Microsoft Excel"