Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Mar 2009
    Thanked 0 Times in 0 Posts
    I have a visual basic program that works extremely well, the only problem with it is that i have to manually create the different monthly tabs (spreadsheets) each new month. Is there a way for me to automate this procedure so that there is absolutely no manual intervention at all.

     Dim strValue As String
    strValue = Me.txtCA7.Value
    Dim rng As Range
    Dim iRow As Long
    Dim Worksheet As String
    Dim ws As Worksheet
    Set ws = Worksheets(Format(Me.txtSCheduledDate, "MMMYYYY"))

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts
    Welcome to the Lounge!

    You could use something like this:
    Dim ws As Worksheet
    Dim strName As String
    strName = Format(Me.txtSCheduledDate, "MMMYYYY")
    On Error Resume Next
    Set ws = Worksheets(strName)
    If ws Is Nothing Then
      Set ws = Worksheets.Add
      ws.Name = strName
    End If
    On Error GoTo 0
    Note: I would avoid using Worksheet as the name for a variable (in Dim Worksheet As String), since Worksheet is a built-in object in Excel VBA.

Posting Permissions

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