Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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.

  #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
  #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


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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.