View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Heine Heine is offline
external usenet poster
 
Posts: 49
Default Add sheets using macro

That works like a charm, Gert. Thanks so much for taking your time to
help. Wish I were better at writing these codes:-)


Best Regards

Heine
Gert wrote:
Sorry Heine, it was my faulth,
it depends on the moment when you add the new sheet.
I've replaced the line Sheets.Add and now it only adds a sheet when
"Raabalance" isn't in use allready

Sub SheetInsert()

Dim strNameSheet As String
Dim boolFound As Boolean
Dim MySheets As Worksheet

boolFound = False
strNameSheet = "Raabalance"
For Each MySheets In Worksheets
If MySheets.Name = strNameSheet Then boolFound = True
Next
If boolFound Then
MsgBox ("this sheet already exists")
Else
Sheets.Add
ActiveSheet.Name = strNameSheet
End If
End Sub


hopes this works as you wanna have it
best regards
Gert