SheetAdd_ANmar

Adds a sheet to a workbook, after checking if workbook is open
Checks if worksheet with that name is already found, then deletes it or not based on passed argument

Function SheetAdd_ANmar(SheetNa, Optional ThisWB = "", Optional DeleteitifFound = 0)
'
Rett = False
Createit = 0
If ThisWB = "" Then ThisWB = ThisWorkbook.Name
If FindFile(ThisWB) Then
If FindSheet(SheetNa, ThisWB) Then
If DeleteitifFound = 1 Then
SheetDelete_ANmar SheetNa, ThisWB
Createit = 1
End If
Else
Createit = 1
End If
If Createit = 1 Then
Workbooks(ThisWB).Worksheets.Add
Workbooks(ThisWB).ActiveSheet.Name = SheetNa
Rett = True
End If
End If
ByeBye:
SheetAdd_ANmar = Rett
End Function

SheetNa, Optional ThisWB = "", Optional DeleteitifFound = 0

Views 626 Downloads 243

'FindFile', 'FindSheet', 'SheetDelete_ANmar', 'Sheet', 'Sheets', 'tab', 'tabs', 'add', 'new', 'create', 'insert', 'workbook', 'excel', 'delete'

ANmarAmdeen
542
Attachments
Components VBA-Excel
Revisions

v1.0