pivot table VBA misery

RET79

Well-known Member
Joined
Mar 19, 2002
Messages
526
Hi there.

Can anyone here explain to me why this code doesnt work??


Set rngpivotcol = Range([A12], [A65536].End(xlUp))

y = rngpivotcol.Cells.count

ReDim pivotcol(1 To y, 1)

pivotcol = rngpivotcol

For i = 2 To y
Debug.Print pivotcol(i, 1)

ActiveSheet.PivotTables("PivotTable1").PivotFields(Array(i)).Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)


Next i

ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=pivotcol


It's this last line that doesn't work. I thought that RowFields liked arrays. Oh well, any help appreciated folks.

RET79
This message was edited by RET79 on 2002-04-18 16:56
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi RET79,

I believe that the problem is that when the helps say that the RowFields parameter will accept an array it really means that it will accept a Variant CONTAINING an array (a subtle distinction, I'll admit). I think it will work if you assign the array to a variant like this:

Dim x As Variant
x = pivotcol
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:=x
 
Upvote 0
Has anyone got any fresh ideas about this one?

Also, I don't like the code I have written to say no to subtotals, i.e. the line:


ActiveSheet.PivotTables("PivotTable1").PivotFields(Array(i)).Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)


I wonder if anyone has a more elegant way of doing this.

Many thanks,

RET79
This message was edited by RET79 on 2002-05-01 16:42
 
Upvote 0
OK, sorry about this but I am calling this message up one more time. Any ideas appreciated, otherwise its hard coding for me (sigh)

RET79
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,557
Latest member
richa mishra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top