View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kevin B Kevin B is offline
external usenet poster
 
Posts: 1,316
Default 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