Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 318
Default code does not work anymore

Hello Excel 2002 - I have a spreadsheet that I rename every month with
the currents month's name,( e.g. Sales for July 2008 ) and has a worksheet
for each work day of the month and a summary tab at the end. I've been
using the following code but the code does not work anymore .
above the code first box is worksheet second box is Selection change
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ActiveSheet
newname = Application.WorksheetFunction.Text(Range("J1"), "mm-dd-yy")
ActiveSheet.Name = newname
End With
End Sub

thanks in advance

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default code does not work anymore

You should use the change event, and check if cell J1 is changed:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$J$1" Then Exit Sub
On Error Resume Next
With Target.Parent
.Name = Format(.Range("J1"), "mm-dd-yy")
End With
End Sub

HTH,
Bernie
MS Excel MVP


"Wanna Learn" wrote in message
...
Hello Excel 2002 - I have a spreadsheet that I rename every month with
the currents month's name,( e.g. Sales for July 2008 ) and has a worksheet
for each work day of the month and a summary tab at the end. I've been
using the following code but the code does not work anymore .
above the code first box is worksheet second box is Selection change
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ActiveSheet
newname = Application.WorksheetFunction.Text(Range("J1"), "mm-dd-yy")
ActiveSheet.Name = newname
End With
End Sub

thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 342
Default code does not work anymore

Use this if you want it to change any time someone clicks anywhere on the
worksheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim newname As String
With ActiveSheet
newname = ActiveSheet.Range("J1").Value & " " & CStr(Date$)
Debug.Print newname
ActiveSheet.Name = newname
End With
End Sub

Use this if you want the sheet name to change only when cell J1 is changed:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$J$1" Then Exit Sub
On Error Resume Next
With Target.Parent
.Name = ActiveSheet.Range("J1").Value & " " & CStr(Date$)
End With
End Sub

"Wanna Learn" wrote:

Hello Excel 2002 - I have a spreadsheet that I rename every month with
the currents month's name,( e.g. Sales for July 2008 ) and has a worksheet
for each work day of the month and a summary tab at the end. I've been
using the following code but the code does not work anymore .
above the code first box is worksheet second box is Selection change
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With ActiveSheet
newname = Application.WorksheetFunction.Text(Range("J1"), "mm-dd-yy")
ActiveSheet.Name = newname
End With
End Sub

thanks in advance

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
Macros do not work anymore! fak119 Excel Discussion (Misc queries) 4 September 28th 09 05:54 PM
I am having difficulty getting nested subtotals to work anymore?! Alyse Excel Worksheet Functions 0 April 30th 07 05:00 PM
Double clicking Field does not work anymore in Pivot Table... AK Excel Discussion (Misc queries) 3 January 2nd 07 09:45 PM
Why doesn't it work anymore? daver39 Excel Discussion (Misc queries) 1 November 13th 06 04:56 PM
formulas don't work anymore john Excel Discussion (Misc queries) 3 November 18th 05 04:11 PM


All times are GMT +1. The time now is 09:17 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"