LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I limit number of sheets in a Workbook?


I have been scratching around in vain to write a code that will limit
the number of Worksheets in a Workbook to fall within a certain range.
For example, prevent the user from inserting new sheets if a maximum of
10 sheets is reached, and contrariwise, to prevent deletions if number
of sheets is 3.

I have a sneaking feeling that this task will need a Workbook event but
the following code failed me. In spite of the code, insertions/deletions
are carried out after the Msgbox displays. TIA

Private Sub Workbook_NewSheet(ByVal Sh As Object)
If Sheets.Count 5 Then
MsgBox "You cannot have MORE THAN 5 sheets"
Exit Sub
End If
If Sheets.Count < 3 Then
MsgBox "You cannot have LESS THAN 3 sheets"
Exit Sub
End If
End Sub


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=473686

 
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
want to share workbook but limit the sheets each user sees Mikekne Excel Worksheet Functions 5 November 5th 08 04:32 PM
how do I limit the Number of rows in an excel 2007 workbook Mike Setting up and Configuration of Excel 3 June 18th 08 05:49 PM
How do I limit the number of times an Excel workbook can be opene. Chris Excel Discussion (Misc queries) 8 January 19th 05 04:02 PM
Limit on number of Sheets in a Workbook? Mr B[_3_] Excel Programming 1 April 8th 04 08:03 PM
Limit on number of embedded controls in a workbook? Ken Dahlberg Excel Programming 1 October 8th 03 12:40 PM


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