Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pieman
 
Posts: n/a
Default Worksheet Names as a Date

Hi

Is it possible to change the name of a worksheet tab to show the current
year and another sheet to show the previous year? If it helps, each sheet
has the
correct year in one of the cells using the TODAY function.

I expect the only way to do this is using the VB editor, but does anyone
know the code to achieve this?

Thanks
Simon

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Chip Pearson
 
Posts: n/a
Default Worksheet Names as a Date

If cell A1 contains the date, then

Worksheets(1).Name = Year(Range("A1").Value)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Pieman" wrote in message
...
Hi

Is it possible to change the name of a worksheet tab to show
the current
year and another sheet to show the previous year? If it helps,
each sheet
has the
correct year in one of the cells using the TODAY function.

I expect the only way to do this is using the VB editor, but
does anyone
know the code to achieve this?

Thanks
Simon



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ardus Petus
 
Posts: n/a
Default Worksheet Names as a Date

ThisWorkbook.worksheets("Sheet1").Name = Year(Date)
ThisWorkbook.worksheets("Sheet21").Name = Year(Date)-1

HTH
--
AP

"Pieman" a écrit dans le message de
...
Hi

Is it possible to change the name of a worksheet tab to show the current
year and another sheet to show the previous year? If it helps, each sheet
has the
correct year in one of the cells using the TODAY function.

I expect the only way to do this is using the VB editor, but does anyone
know the code to achieve this?

Thanks
Simon



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pieman
 
Posts: n/a
Default Worksheet Names as a Date

Hi

I tried the code you suggested in the VB editor for each sheet and nothing
changed. Could this be because there is already some extra code for this
sheet as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E4:E6")) Is Nothing _
Or Target.Count < 1 _
Then Exit Sub
Application.EnableEvents = False
With Target
If .Value = "" Then
Range("E4:E6").Value = ""
Else
Select Case Target.Row
Case 4 'Weekly
Range("E5").Value = .Value * 52 / 12
Range("E6").Value = .Value * 52
Case 5 'Monthly
Range("E4").Value = .Value * 12 / 52
Range("E6").Value = .Value * 12
Case 6 'Yearly
Range("E4").Value = .Value / 52
Range("E5").Value = .Value / 12
End Select
End If
End With
Application.EnableEvents = True
End Sub


"Ardus Petus" wrote:

ThisWorkbook.worksheets("Sheet1").Name = Year(Date)
ThisWorkbook.worksheets("Sheet21").Name = Year(Date)-1

HTH
--
AP

"Pieman" a écrit dans le message de
...
Hi

Is it possible to change the name of a worksheet tab to show the current
year and another sheet to show the previous year? If it helps, each sheet
has the
correct year in one of the cells using the TODAY function.

I expect the only way to do this is using the VB editor, but does anyone
know the code to achieve this?

Thanks
Simon




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ardus Petus
 
Posts: n/a
Default Worksheet Names as a Date

Where did you plce the code?
It should be within a Sub, in a Module.

NOT in the Worksheet's Code

HTH
--
AP

"Pieman" a écrit dans le message de
...
Hi

I tried the code you suggested in the VB editor for each sheet and nothing
changed. Could this be because there is already some extra code for this
sheet as follows:





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pieman
 
Posts: n/a
Default Worksheet Names as a Date

OK, is this correct...

Public Sub Worksheet_Name()
ThisWorkbook.Worksheets("Sheet2").Name = Year(Date)
ThisWorkbook.Worksheets("Sheet3").Name = Year(Date) - 1
End Sub


"Ardus Petus" wrote:

Where did you plce the code?
It should be within a Sub, in a Module.

NOT in the Worksheet's Code

HTH
--
AP

"Pieman" a écrit dans le message de
...
Hi

I tried the code you suggested in the VB editor for each sheet and nothing
changed. Could this be because there is already some extra code for this
sheet as follows:




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
How to find hidden names on an Excel worksheet ? Jon Sipworth Excel Worksheet Functions 2 December 13th 05 06:16 PM
Tracking worksheet names in functions locutus243 Excel Worksheet Functions 8 December 5th 05 08:56 PM
Lookup cell value using list of worksheet names amaranth Excel Worksheet Functions 5 August 8th 05 04:59 PM
Using worksheet names in formulas WightRob Excel Discussion (Misc queries) 2 August 7th 05 07:17 PM
Transferring date from multiple worksheets to a "totals" worksheet. tonyDeBrasco Excel Discussion (Misc queries) 3 July 22nd 05 05:43 PM


All times are GMT +1. The time now is 01:54 PM.

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"