LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Pivot Table - Object variable or with block variable not set?

Is there really an ActiveSheet?

--
George Nicholson

Remove 'Junk' from return address.


"Darrell Wesley" wrote in message
...
I have a visual basic application that creates a Excel spreadsheet and

then creates a pivot table from the data found on Sheet1. The first pass
thru the code everything works fine but if I send it thru this section of
code again without closing the application I get an:

Run_Time error '91'

Object variable or with block variable not set

The code for the pivot table creation is as follows:

With ObjExcel
.ActiveWorkbook.PivotCaches.Add(SourceType:=xlData base, SourceData:= _
"Sheet1!R1C1:R" & row1 & "C20").CreatePivotTable

TableDestination:="", TableName:= _
"PivotTable1"
.ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3,

1)
.ActiveSheet.Cells(3, 1).Select
With .ActiveSheet.PivotTables("PivotTable1")
.ColumnGrand = False
.RowGrand = False
.SmallGrid = False
End With
.ActiveSheet.PivotTables("PivotTable1").AddFields

RowFields:=Array("Run#", _
"WMW", "WML", "COIL HGT")
.ActiveSheet.PivotTables("PivotTable1").PivotField s("Qty").Orientation

= _
xlDataField

.ActiveSheet.PivotTables("PivotTable1").PivotField s("WML").Subtotals =

Array( _
False, False, False, False, False, False, False, False, False,

False, False, False)

.ActiveSheet.PivotTables("PivotTable1").PivotField s("WMW").Subtotals =

Array( _
False, False, False, False, False, False, False, False, False,

False, False, False)

.ActiveSheet.PivotTables("PivotTable1").PivotField s("Run#").Subtotals

= Array( _
False, False, False, False, False, False, False, False, False,

False, False, False)
.ActiveSheet.PivotTables("PivotTable1").PivotField s("Count of

Qty").Function = _
xlSum
.ActiveSheet.PivotTables("PivotTable1").PrintTitle s = True
.ActiveSheet.Name = "BOXES"
End With

The line that gets the error is

.ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)

Any ideas as to what is happening?




 
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
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
object variable or with block variable not set Diego Excel Discussion (Misc queries) 1 August 9th 05 02:46 PM
Ogilvy Help :) - "Object variable or With block variable not set" Mike Taylor Excel Programming 1 December 16th 03 07:21 AM
Error 91 - Object variable with block variable not set Jim[_35_] Excel Programming 2 November 27th 03 03:34 AM
Object Variable or With Block variable not set? Chris M.[_3_] Excel Programming 3 August 26th 03 04:30 PM


All times are GMT +1. The time now is 04:33 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"