Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default create named worksheet based on existing numeration

Greetings all.
Hope your respective weekends were enjoyable.
I have recorded, and modified a macro that creates a worksheet within an
existing workbook. For now, I've just set the name of the worksheet to be "A."
I would like to now have this new worksheet named within the existing
framework of the workbook.
I.e., for this type of worksheet, we typically name them by a ordinal
number-- 1 through N.
In one workbook we may only be up to 5, and another could easily be upwards
of 70, or more.
Presently, the code for my worksheet name is:

Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "A"

What would I use to make the name of the worksheet the next number inline
for the respective worksheet?
I appreciate your responses.
Best.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default create named worksheet based on existing numeration-- addendum

Sometrhing I forgot to add.
I've tried

Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = sheets.count

And

Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = sheets.count+1

Only to realize that this also counts the hidden worksheets.
I've like to have it not count the hidden worksheets.

Again, thank you.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default create named worksheet based on existing numeration

Hi
If the first worksheet is "A1", the second "A2" and so on then use

Sheets(Sheets.Count).Name = "A"&Sheets.Count

If there are other worksheets in the workbook without this naming
structure then you will have to keep track of the last sheet number
and any deletion of numbered sheets. Could be a bit tricky in that
case, so get back if that is what you need.

regards
Paul

On Feb 25, 3:29*pm, SteveDB1
wrote:
Greetings all.
Hope your respective weekends were enjoyable.
I have recorded, and modified a macro that creates a worksheet within an
existing workbook. For now, I've just set the name of the worksheet to be "A."
I would like to now have this new worksheet named within the existing
framework of the workbook.
I.e., for this type of worksheet, we typically name them by a ordinal
number-- 1 through N.
In one workbook we may only be up to 5, and another could easily be upwards
of 70, or more.
Presently, the code for my worksheet name is:

Sheets.Add After:=Sheets(Sheets.Count)
* Sheets(Sheets.Count).Name = "A"

What would I use to make the name of the worksheet the next number inline
for the respective worksheet?
I appreciate your responses.
Best.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default create named worksheet based on existing numeration

Hi SteveDB1,

There are a number of topics on this website if you do a search for
"count specific sheets"

However if ALL your sheets are numbered 1,2 ,3 4, etc then your next
sheet will be Sheet.Count + 1 if you do the count before creating the
new sheet, or simply Sheet.Count if after.

If you have other types of sheet names you might want to set up a
'counter & loop thru all the sheets testing to see if the name =
integer (you will have to convert the name to an integer as sheet
names are strings)

Hope this helps. Repost if you get suck

Regards

Michael.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create new records from existing ones based on 'rule'? msnyc07 Excel Worksheet Functions 1 May 28th 10 02:38 PM
Create named ranges in Column on worksheet eholz1 Excel Programming 0 January 24th 08 01:41 AM
Macro to create a new worksheet that is a copy of an existing one? Kai Cunningham[_2_] Excel Programming 3 July 3rd 07 02:30 AM
Create Worksheet From Values in Existing Cells Using Existing Worksheet as Template. Ardy Excel Programming 18 November 29th 06 03:23 AM
Dynamically create worksheets in Excel based off existing data? tlozier Excel Discussion (Misc queries) 1 September 10th 05 12:25 AM


All times are GMT +1. The time now is 05:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"