Naming a new sheet.

  • Thread starter Thread starter Rich Cooper
  • Start date Start date
R

Rich Cooper

I am adding a new sheet and trying to name that sheet.
I can add a sheet and i can name a sheet using vba
But when i try to do them together it doesn't work.
I can add a sheet. Then i have to fugure out what it is named and then i
can change the name. Is there a simplier way to add a new sheet to a
workbook and change the name?
 
You don't have to figure out what the name is, as the sheet just added
becomes the activesheet. So you could use

Worksheets.Add
Activesheet.Name = "Rich"

or you could use object variables

Set newSheet = Worksheets.Add
newSheet.Name = "Rich"

or even create and name in one go

Worksheets.Add.Name = "Rich"

My preference is usually the second, as you have a handle to the worksheet
that you can use at any time.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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