View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default Using a macro to create multiple PivotTables

Hi Enbentro,

Can anyone see what I may have altered so as to make macro unusable? I wish
I could remember!


All I can see quickly, is that your code will fail with sheetnames that contain
spaces in them. This line of code:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
ActiveSheet.Name & "!r1c1:r170c4").CreatePivotTable

needs to be changed to:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'" & ActiveSheet.Name & "'!r1c1:r170c4").CreatePivotTable

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com