Add sheets using macro
Thanks Gert,
thatīs quite crafty. One or two minor details, though:
I would like, if possible to avoid the use of an inputbox.
The macro still adds sheets called sheet 5, sheet 6, sheet 7 etc - can
I avoid this problem?
/Heine
Gert wrote:
the extended version
Sub SheetInsert()
Dim strNameSheet As String
Dim boolFound As Boolean
Dim MySheets As Worksheet
Sheets.Add
boolFound = False
strNameSheet = InputBox("give sheet name")
For Each MySheets In Worksheets
If MySheets.Name = strNameSheet Then boolFound = True
Next
If boolFound Then
MsgBox ("this sheet already exists")
Else
ActiveSheet.Name = strNameSheet
End If
End Sub
|