adding worksheet with spcific name

  • Thread starter Thread starter SotjeRuud
  • Start date Start date
S

SotjeRuud

Hi there,

Can anyone help me with the code to add a worksheet in an excelsheet with a
specific name?
The name should be "data sheet"

thx in advance
Ruud
 
Hi, try this

Workbooks.Add
ActiveSheet.Name = "data sheet"

Filip
 
Sorry,
once more and better:

Sheets.Add
ActiveSheet.Name = "LongProfile"

In the first case I added workbook

Cus :-)

Filip
 
Ruud,

following should get u on your way..

Sub AddDataSheet()
Dim ws As Worksheet

On Error Resume Next
Set ws = Worksheets("data sheet")
On Error GoTo 0
If ws Is Nothing Then
Set ws = Worksheets.Add
ws.Name = "data sheet"
Else
'handle sheet exists here
End If
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top