Inserting a sheet with a macro

  • Thread starter Thread starter Bowly
  • Start date Start date
B

Bowly

Hi

I'm just getting into this VBA lark with Excel and have come across a
problem! :confused:

I'm used to creating macros by pressing the little record button
selecting the rows and editing them as usual. I then press play and it
all happens magically in front of my eyes!

My problem, however, is how to insert a worksheet without it
automatically being named "sheet1". When this happens, I am unable to
run this macro more than once in any given session. Is there a way I
can make this sheet name generic so that when I run the macro a new
sheet will be opened whether it's called "sheet1" "sheet2" or "sheet3"
etc...

Please help!! :eek:

Cheers
Bowly
 
Surely, Worksheets.Add creates a generic name, next in the series?
 
And you could just rename the new worksheet to what you want.

Dim newWks as worksheet
set newwks = worksheets.add
newwks.name = "niceUniqueNameHere"
 

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