Saintsman,
I have coded this to allow you to add multiple sheets at a time while hiding
rows as last time. I am quessing that is what you mean with your last
question.
This code will ask for the number of sheets to add with the hidden rows and
then loop through the number requested. I hope this is what you were asking
for.
JR Form
'Declare a global boolean variable and call it bolProcessing
Public bolProcessing As Boolean
'
Private Sub Workbook_NewSheet(ByVal Sh As Object)
'When adding multiple sheets this will stop the refiring of the Saintsman
code below.
If bolProcessing Then Exit Sub
Call SaintsMan
End Sub
Sub SaintsMan()
Dim Msg, Style, Title, Response, Default, Sheets2Add
Msg = "Do you want to hide rows ?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Hide Some"
'If you will be adding more than one often change the default to the number
Default = "1"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
'Set the new variable to true
bolProcessing = True
Message = "How many sheets do you want to add with hidden rows?"
Sheets2Add = InputBox(Message, Title, Default)
'hide the rows in the current activesheet
ActiveSheet.Rows("45:50").Select
Selection.EntireRow.Hidden = True
Sheets2Add = Sheets2Add - 1
'set up a loop to add sheets
Do Until Sheets2Add = 0
Sheets.Add
ActiveSheet.Rows("45:50").Select
Selection.EntireRow.Hidden = True
Sheets2Add = Sheets2Add - 1
Loop
'reset the global variable so the process can be repeated
bolProcessing = False
Else
Exit Sub
End If
End Sub