Results 1 to 4 of 4

Thread: Need Help: Check Sheet Name Exists Before Creating New W/ Same Name

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Apr 2016
    Posts
    9
    Location

    Need Help: Check Sheet Name Exists Before Creating New W/ Same Name

    Hello - I've been searching for a while and found several things that may work but they all seem fairly bloated for my purposes. What I am creating is an attendance tracker for my employees. I have it creating a new sheet and populating the dates and other data when you click "start new month". Others use this as well. If one were to create a new sheet within the same month, there will be a run-time error due to the fact the sheet already exists.

    I would like it to function as it does but in the event someone does want to create a new month(sheet) and that current months sheet exists already, I would like an input box so they can enter a name of their choosing.
    Private Sub Cont_Click()
    Nmth.Hide
    Sheets("Empty").Copy Before:=Sheets(1)
    ActiveSheet.Name = Format(Date, "MMMM-YY")
    Cells(45, "A") = Format(Date, "MMMM")
    Dim i As Integer
    Dim counter As Integer
    Dim days As Integer
    days = Cells(44, "A")
    counter = 0
    i = 1
    Cells(1, "D").Select
    Do While counter < Cells(44, "A").Value
    ActiveCell.Value = Cells(45, "A").Value & i
    ActiveCell.Offset(0, 1).Select
    counter = counter + 1
    i = i + 1
    Loop
    End Sub
    Thanks for any help. I'm out of practice!
    Last edited by Bob Phillips; 04-08-2016 at 04:06 AM. Reason: Added code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •