View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Determine If Pivot Table Exists

dim wks as worksheet
dim iCtr as long
for each wks in activeworkbook.worksheets
for iCtr = 1 to wks.pivottables.count
next ictr
next wks

Or if you just want to check...

if wks.pivottables.count 0 then
'it has at least one pt
end if


ridawg wrote:

Hey,

I need to loop through all the worksheets in a workbook and for each
worksheet with a pivot table I want to cleanup the pivot cache.

I've done this for workbooks where all the worksheets have a pivot table but
I'm having trouble doing this where some worksheets have a pivot table and
some don't. My guess is I need to determine if a worksheet has a pivot table
and if it does clean it up otherwise move on to the next spreadsheet.

I'm converting existing VBA code to VB.NET 2005 so an example using either
language would work for me.

Thanks for the help!

--
-ridawg


--

Dave Peterson