Consulting

Results 1 to 2 of 2

Thread: create a sequal

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    create a sequal

    hello
    i would like to reproduce a worksheet in a sequal manner.
    namely report1,report2 and so on.
    what is wrong?
    [VBA]Sub sheetsequal()
    Dim mysheet As Worksheet
    Dim mybase As String
    Dim mysuffix As Integer
    Set mysheet = Worksheets.Add
    mybase = "2006"
    mysuffix = 1
    On Error Resume Next
    mysheet.name = mybase & mysuffix
    If err.number <> 0 Then
    mysuffix = mysuffix + 1
    mysheet.name = mybase & mysuffix
    End If
    End Sub
    [/VBA]
    thanks
    moshe

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Try this Moshe:
    [VBA]
    Sub AddNewSheets()
    Dim TotalSheets
    TotalSheets = Worksheets.Count - 1
    Worksheets.Add after:=Worksheets(Worksheets.Count)
    ActiveSheet.Name = "2006 " & TotalSheets + 1
    ActiveSheet.Visible = True

    End Sub
    [/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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