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


Public

Tested

My Own Work
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 1278 Downloads 474

VBA-Excel Components
ANmarAmdeen
642
Attachments
Revisions

v1.0