Checks that a sheet exists and then switches to it positioning into the specified column and in the first empty cell

PHOTO EMBED

Wed Sep 08 2021 06:06:20 GMT+0000 (UTC)

Saved by @Darkleech #vba

Public Sub Sheet_Select(Sheet_Name As String, Dest As String, Del_Sheet As Boolean)
' This checks that a sheet exists and then switches to it positioning into the specified column and in the first empty cell.
    Dim flag As Boolean
    Dim ws As Worksheet
    
    Application.DisplayAlerts = False
    flag = "False"
    For Each ws In ActiveWorkbook.Sheets
        If ws.Name = Sheet_Name Then
            If Del_Sheet Then
                Sheets(Sheet_Name).Delete
            Else
                flag = "True"
            End If
        End If
    Next ws
    If Not flag Then Sheets.Add(After:=Sheets(Sheets.Count)).Name = Sheet_Name
    Sheets(Sheet_Name).Select
    Cells(Rows.Count, Dest).End(xlUp).Offset(Abs(Cells(Rows.Count, Dest).End(xlUp).Value <> ""), 0).Select
    Application.DisplayAlerts = True
End Sub
content_copyCOPY