View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
tg_evil tg_evil is offline
external usenet poster
 
Posts: 1
Default Pivot Table - How do I count number of columns?


Hi Vicky,

you could try this code:


Code:
--------------------
Sub pivot_count_columns()

'********Select the Pivot table*********
'using name of the pivot
'ActiveSheet.PivotTables("PivotTable4").PivotSelec t PivotFields, xlDataAndLabel
'or using a known cell in the pivot
ActiveSheet.Range("q11").PivotTable.PivotSelect PivotFields, xlDataAndLabel

'if you want to count columns containing data only use xlDataOnly instead of xlDataAndLabel
'or if you want the number fo columns contining labels only use xlLabelOnly instead of xlDataAndLabel

'********Cont columns in selection**********
i = Selection.Columns.Count
'*********Check**********
MsgBox i

End Sub
--------------------



Hope this helps

tg


--
tg_evil
------------------------------------------------------------------------
tg_evil's Profile: http://www.excelforum.com/member.php...o&userid=37176
View this thread: http://www.excelforum.com/showthread...hreadid=568850