Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 10th, 2004, 12:18 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to name worksheet by Month

I know how to rename the worksheet
Dim i As Integer
For i = 1 To ActiveWorkbook.Sheets.Count
    Sheets(i).Name = "Result" & i
Next

but don't know how to name worksheet by Month or year. Pls advise. thx.

Reply With Quote
  #2 (permalink)  
Old April 10th, 2004, 12:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is this what you need?:

Dim i As Integer
For i = 1 To ActiveWorkbook.Sheets.Count
   Sheets(i).Name = MonthName(i)
Next
Reply With Quote
  #3 (permalink)  
Old April 10th, 2004, 01:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use the immediate window to see this one:

Sub ShtName()
Dim i, o As Integer
For i = 1 To 24
    If i < 13 Then
        Debug.Print MonthName(i) & "-" & Year(Now)
    Else
        o = i - 12
        Debug.Print MonthName(o) & "-" & Year(Now) + 1
    End If
Next
End Sub

Just change the code to use it with sheets - max 24
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting month name to month number kalyanykk SQL Server 2005 7 August 19th, 2008 10:37 PM
month calendar bschleusner C# 2005 0 April 13th, 2007 09:46 PM
query Current Month, Month+1, Month+2, Month+3 anterior Access 2 September 24th, 2006 08:25 PM
Days in a Month jmss66 Classic ASP Basics 3 April 11th, 2005 05:57 PM
Getting the current month Regornil JSP Basics 1 July 19th, 2004 09:01 PM



All times are GMT -4. The time now is 10:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.