Here is a rookie VBA question stemming from 3d's post about opening a workbook template with number of sheets at user discretion. Jimboy's code works great:
http://216.92.17.166/board/viewtopic.php?topic=27921&forum=2
However I cannot leave well enough alone. I would like to hide the original sheet so that the user always has a blank template if necessary. The problem is, rather than hiding Sheet1, my code either hides all the other sheets or gives runtime error 424. Due to inexperience with WITH.
Can anyone spot issues in code below - much obliged for improving my understanding.
Alriemer
Sub auto_open()
'
Application.ScreenUpdating = False
Dim no_of_sheets
Dim counter As Integer
counter = 0
no_of_sheets = InputBox("How many sheets do you need?", "No. of sheets")
Do Until no_of_sheets = counter
Sheets("Sheet1").Copy Before:=Sheets(1)
counter = counter + 1
Loop
With Worksheets("Sheet1")
.Visible = xlSheetHidden
End With
Application.ScreenUpdating = True
Sheet2.Select
End Sub
http://216.92.17.166/board/viewtopic.php?topic=27921&forum=2
However I cannot leave well enough alone. I would like to hide the original sheet so that the user always has a blank template if necessary. The problem is, rather than hiding Sheet1, my code either hides all the other sheets or gives runtime error 424. Due to inexperience with WITH.
Can anyone spot issues in code below - much obliged for improving my understanding.
Alriemer
Sub auto_open()
'
Application.ScreenUpdating = False
Dim no_of_sheets
Dim counter As Integer
counter = 0
no_of_sheets = InputBox("How many sheets do you need?", "No. of sheets")
Do Until no_of_sheets = counter
Sheets("Sheet1").Copy Before:=Sheets(1)
counter = counter + 1
Loop
With Worksheets("Sheet1")
.Visible = xlSheetHidden
End With
Application.ScreenUpdating = True
Sheet2.Select
End Sub