Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Omit page with no data when use "show page"

I have a VBA to "show page" by user email at a pivot table. However, some of
them are "empty" and without data, how to omit/ delete those worksheets
without data?

Sheets("AllData").Select
ActiveSheet.PivotTables("PivotTable1").ShowPages PageField:="User email"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Omit page with no data when use "show page"


Is there a particular cell in each worksheet that will always have
content in it?
You could cycle through all the sheets in your workbook and check that
cell. If the cell is empty then you could delete the empty sheet (or
even just hide the empty sheet).

Sub DeleteEmpty()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If IsEmpty(sh.Range("A1")) Then
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
End If
Next sh
End Sub

Give this code a try and see if it does what you are after.

HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381176

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Omit page with no data when use "show page"

The pivot table will create worksheets with "@" as worksheet name.

For each page if it is empty, the grand total at pivot table will be zero.

"bhofsetz" wrote:


Is there a particular cell in each worksheet that will always have
content in it?
You could cycle through all the sheets in your workbook and check that
cell. If the cell is empty then you could delete the empty sheet (or
even just hide the empty sheet).

Sub DeleteEmpty()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If IsEmpty(sh.Range("A1")) Then
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
End If
Next sh
End Sub

Give this code a try and see if it does what you are after.

HTH


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381176


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Omit page with no data when use "show page"


Is the grand total in the same cell on each pivot table created?

If so then you can check to see if this cell is 0 and delete thos
sheets

--
bhofset
-----------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...fo&userid=1880
View this thread: http://www.excelforum.com/showthread.php?threadid=38117

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Omit page with no data when use "show page"

Not the same cell. Is it any object to describe the grand total of pivot
table? So i can check if the grand total equals zero then delete the sheets.

"bhofsetz" wrote:


Is the grand total in the same cell on each pivot table created?

If so then you can check to see if this cell is 0 and delete those
sheets.


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381176


Reply
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
How do I use Page Break Preview without seeing "PAGE" in sheet? Aditya Thakur Excel Discussion (Misc queries) 1 October 7th 08 11:38 PM
Are the "page setup" layout settings overwritten by page preview adjustments ? Jeff Korn Excel Discussion (Misc queries) 8 April 8th 08 01:24 PM
How do I lighten the word "Page" (and number) in Page Break View? ExcelJockey Excel Discussion (Misc queries) 0 June 29th 06 07:26 PM
How do you get "Show Page" functionality in MSExcel PivotTables Engineering Accountant Excel Discussion (Misc queries) 1 February 27th 06 09:30 PM
"Can't shift excess data off page"??? Ed[_9_] Excel Programming 2 August 12th 03 09:53 PM


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