Add MsgBox in this VBA

Viewed 58

i have used this vba to find sheet and create sheet in workbook

here i want to show this first msgbox MsgBox ("Sheet Already Exist") when i enter sheet name in inputbox after goto that sheet Sheets.Select

if given sheet not found then show this second msgbox MsgBox ("Given Sheet Name of " & "(" & Name & ")" & " Not Found Do You Want Create New Sheet with " & "(" & Name & ")" & " Click Yes") vbYesNo

Sub SheetExists()
    
    Dim p As Integer
    Dim Name As String
    
    Name = InputBox("Find Sheet is Exist Or Not")
    
    MsgBox ("Sheet Already Exist")
    
    Sheets(Name).Select
    
    For p = 1 To Worksheets.Count
        If Worksheets(p).Name = Name Then Exit Sub
    Next
    Sheets.Add(After:=Sheets(Sheets.Count)).Name = Name
    MsgBox ("New Sheet Created with " & "(" & Name & ")")

End Sub


0 Answers
Related