+ Reply to Thread
Results 1 to 2 of 2

How to add a new sheet with a name

  1. #1
    Forum Contributor
    Join Date
    10-03-2005
    Posts
    183

    How to add a new sheet with a name

    Hi

    I'm trying to add a sheet for so to name it "formulas".

    How can I do that?

  2. #2
    Kevin B
    Guest

    RE: How to add a new sheet with a name

    The following code checks all the worksheets in the workbook to see if there
    is sheet named "Formulas" already present in the file. If it does exist,
    nothing happens, if it doesn't exist a new worksheet is added and named.

    Sub AddSheet()

    Dim ws As Worksheet
    Dim wb As Workbook
    Dim strName As String
    Dim blnFound As Boolean

    Set wb = ActiveWorkbook

    For Each ws In wb.Worksheets
    strName = ws.Name
    If strName = "Formulas" Then
    blnFound = True
    Exit For
    Else
    blnFound = False
    End If
    Next ws

    If Not blnFound Then
    ActiveWorkbook.Worksheets.Add
    ActiveSheet.Name = "Formulas"
    End If

    End Sub

    --
    Kevin Backmann


    "Ctech" wrote:

    >
    > Hi
    >
    > I'm trying to add a sheet for so to name it "formulas".
    >
    > How can I do that?
    >
    >
    > --
    > Ctech
    > ------------------------------------------------------------------------
    > Ctech's Profile: http://www.excelforum.com/member.php...o&userid=27745
    > View this thread: http://www.excelforum.com/showthread...hreadid=500157
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1