Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Next in Series

Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Next in Series

Howard,

lastsheet = Sheets(Sheets.Count).name ' store the last sheet number
Set Newsheet = Worksheets.Add 'create a newsheet
Newsheet.name = lastsheet + 1 'rename it eg 2003 + 1

The above assumes you added them in order, if not you might consider reading
each sheet name and choosing the highest value before naming the next sheet
after the add

Cheers
Nigel

"Howard" wrote in message
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF





----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default Next in Series

Howard,

Worksheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = CStr(CInt(Worksheets(Worksheets.Count - 1).Name) +
1)

HTH,
Bernie


"Howard" wrote in message
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Next in Series

Thanks to all three of you for your replies. Now I have
some options!
HF
-----Original Message-----
Howard,

Worksheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = CStr(CInt(Worksheets(Worksheets.Count -

1).Name) +
1)

HTH,
Bernie


"Howard" wrote in

message
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add

a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Next in Series

Howard

Here's one way to do it:

Sub AddSheet()
'Leo Heuser, 20 Oct. 2003
Dim LastSheet As Worksheet
Dim SheetName As String

With ActiveWorkbook
Set LastSheet = .Worksheets(.Worksheets.Count)
SheetName = LastSheet.Name
.Worksheets.Add after:=LastSheet
ActiveSheet.Name = LastSheet.Name + 1
End With
End Sub


--
Best Regards
Leo Heuser
Excel MVP

Followup to newsgroup only please.

"Howard" skrev i en meddelelse
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Next in Series

Just another similar idea:

Sub Demo()
Worksheets.Add(After:=Worksheets(Worksheets.Count) ).Name =
Worksheets(Worksheets.Count).Name + 1
End Sub

Using "Sheets" may also work for you:

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

HTH
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Howard" wrote in message
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Next in Series

And just another idea that doesn't use variables. (Assumes your sheet names
are numeric).

Sub Demo()
Sheets(Sheets.Count).Activate
Worksheets.Add , ActiveSheet
ActiveSheet.Name = ActiveSheet.Previous.Name + 1
End Sub

HTH.
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Howard" wrote in message
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Next in Series

Ups! Make that two lines instead. :)

Sub Demo()
Sheets(Sheets.Count).Activate
Worksheets.Add(, ActiveSheet).Name = ActiveSheet.Name + 1
End Sub

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Dana DeLouis" wrote in message
...
And just another idea that doesn't use variables. (Assumes your sheet

names
are numeric).

Sub Demo()
Sheets(Sheets.Count).Activate
Worksheets.Add , ActiveSheet
ActiveSheet.Name = ActiveSheet.Previous.Name + 1
End Sub

HTH.
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Howard" wrote in message
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Next in Series

Thanks, again. Interesting how many ways there are to do
something.
HF
-----Original Message-----
Ups! Make that two lines instead. :)

Sub Demo()
Sheets(Sheets.Count).Activate
Worksheets.Add(, ActiveSheet).Name = ActiveSheet.Name

+ 1
End Sub

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Dana DeLouis" wrote in message
...
And just another idea that doesn't use variables.

(Assumes your sheet
names
are numeric).

Sub Demo()
Sheets(Sheets.Count).Activate
Worksheets.Add , ActiveSheet
ActiveSheet.Name = ActiveSheet.Previous.Name + 1
End Sub

HTH.
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Howard" wrote in

message
...
Running Excel 2000
I have three worksheets: 2001, 2002 and 2003. I can

add a
new worksheet to the end of those worksheets by using
Worksheets.Add Worksheets(Worksheets.Count). Is there

a
way to automatically name it with the next year in the
series (2004) at the same time that I add it?

Thanks,
HF





.

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
Time Series and Creating data points within a series Cristal Excel Discussion (Misc queries) 2 November 30th 09 08:07 PM
User Selectable Series and Number of Series for Line Chart Dave in NJ Charts and Charting in Excel 2 February 23rd 09 12:18 AM
Fill Series Dates: not letting me change the series from year to m Mike Excel Discussion (Misc queries) 1 January 24th 08 05:08 PM
chart data series -- plot a table as a single series hjc Charts and Charting in Excel 7 September 20th 05 05:52 PM
series graph -- one series being added to another series rich zielinski via OfficeKB.com Charts and Charting in Excel 3 March 30th 05 06:23 PM


All times are GMT +1. The time now is 10:20 PM.

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

About Us

"It's about Microsoft Excel"