#1   Report Post  
Mike Allen
 
Posts: n/a
Default Renaming worksheets

I am trying to rename a worksheet by using a defined field (cell). Example,
if I type in Dave Wilson in cell A1, is there a way to define the worksheet
as Dave Wilson, without manually changing it everytime? And as I cahnge
names, the worksheet names will change also...Thanks in advance for your time.
Mike allen
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Mike,

Try this code

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Sh.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike Allen" wrote in message
...
I am trying to rename a worksheet by using a defined field (cell).

Example,
if I type in Dave Wilson in cell A1, is there a way to define the

worksheet
as Dave Wilson, without manually changing it everytime? And as I cahnge
names, the worksheet names will change also...Thanks in advance for your

time.
Mike allen



  #3   Report Post  
David McRitchie
 
Posts: n/a
Default

I believe you already have your answer so will just include this comment.

Would suggest you use "Wilson, Dave" instead of "Dave Wilson" so that
you can sort the worksheet tabs with a macro when you get more than what
you can see directly.
.http://www.mvps.org/dmcritchie/excel...@sortallsheets


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Renaming worksheets

I am trying to do some of the same thing except with merged cells. I am
using cells A1, A2, B1, & B2 for the month and year and I would like that in
the worksheet name. I am making a calendar for a motel to use to book its
rooms.
I opened VBA for the worksheet and put that in, but nothing happened. I
changed the cell range from $a$1 to $a$1..$b$2.

Thanks.

Jeff

"Bob Phillips" wrote:

Mike,

Try this code

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Sh.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike Allen" wrote in message
...
I am trying to rename a worksheet by using a defined field (cell).

Example,
if I type in Dave Wilson in cell A1, is there a way to define the

worksheet
as Dave Wilson, without manually changing it everytime? And as I cahnge
names, the worksheet names will change also...Thanks in advance for your

time.
Mike allen




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Renaming worksheets

Sub namesheet()
mystr = Range("A1") & " " & Range("b1")
'mystr = Range("A1") 'merged a1 & b1
MsgBox mystr
ActiveSheet.Name = mystr
End Sub

--
Don Guillett
SalesAid Software

"Jeff Saunders" <Jeff
wrote in message
...
I am trying to do some of the same thing except with merged cells. I am
using cells A1, A2, B1, & B2 for the month and year and I would like that
in
the worksheet name. I am making a calendar for a motel to use to book its
rooms.
I opened VBA for the worksheet and put that in, but nothing happened. I
changed the cell range from $a$1 to $a$1..$b$2.

Thanks.

Jeff

"Bob Phillips" wrote:

Mike,

Try this code

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Sh.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike Allen" wrote in message
...
I am trying to rename a worksheet by using a defined field (cell).

Example,
if I type in Dave Wilson in cell A1, is there a way to define the

worksheet
as Dave Wilson, without manually changing it everytime? And as I
cahnge
names, the worksheet names will change also...Thanks in advance for
your

time.
Mike allen








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 430
Default Renaming worksheets

Don: I substituted

ActiveSheet.CodeName = mystr

To change to Codename, but get error 450
Wrong number of arguments or invalid property assignment

Can this be corrected to achieve?
TIA,

Jim



"Don Guillett" wrote in message
:

Sub namesheet()
mystr = Range("A1") & " " & Range("b1")
'mystr = Range("A1") 'merged a1 & b1
MsgBox mystr
ActiveSheet.Name = mystr
End Sub

--
Don Guillett
SalesAid Software

"Jeff Saunders" <Jeff
wrote in message
...
I am trying to do some of the same thing except with merged cells. I am
using cells A1, A2, B1, & B2 for the month and year and I would like that
in
the worksheet name. I am making a calendar for a motel to use to book its
rooms.
I opened VBA for the worksheet and put that in, but nothing happened. I
changed the cell range from $a$1 to $a$1..$b$2.

Thanks.

Jeff

"Bob Phillips" wrote:

Mike,

Try this code

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Sh.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike Allen" wrote in message
...
I am trying to rename a worksheet by using a defined field (cell).
Example,
if I type in Dave Wilson in cell A1, is there a way to define the
worksheet
as Dave Wilson, without manually changing it everytime? And as I
cahnge
names, the worksheet names will change also...Thanks in advance for
your
time.
Mike allen




  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Renaming worksheets

try
ThisWorkbook.VBProject.VBComponents(ActiveSheet.Co deName) _
..Name = Format(Range("a1"), "mmmm_yyyy")

--
Don Guillett
SalesAid Software

"Jim May" wrote in message
news:mfqug.103189$IZ2.14130@dukeread07...
Don: I substituted

ActiveSheet.CodeName = mystr

To change to Codename, but get error 450
Wrong number of arguments or invalid property assignment

Can this be corrected to achieve?
TIA,

Jim



"Don Guillett" wrote in message
:

Sub namesheet()
mystr = Range("A1") & " " & Range("b1")
'mystr = Range("A1") 'merged a1 & b1
MsgBox mystr
ActiveSheet.Name = mystr
End Sub

--
Don Guillett
SalesAid Software

"Jeff Saunders" <Jeff
wrote in
message
...
I am trying to do some of the same thing except with merged cells. I am
using cells A1, A2, B1, & B2 for the month and year and I would like
that
in
the worksheet name. I am making a calendar for a motel to use to book
its
rooms.
I opened VBA for the worksheet and put that in, but nothing happened.
I
changed the cell range from $a$1 to $a$1..$b$2.

Thanks.

Jeff

"Bob Phillips" wrote:

Mike,

Try this code

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Sh.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike Allen" wrote in message
...
I am trying to rename a worksheet by using a defined field (cell).
Example,
if I type in Dave Wilson in cell A1, is there a way to define the
worksheet
as Dave Wilson, without manually changing it everytime? And as I
cahnge
names, the worksheet names will change also...Thanks in advance for
your
time.
Mike allen






  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Renaming worksheets

I have read almost everything on how to change sheet names per the value of a
cell, and have had no luck at all working. The code below seems perfect for
my use, but I cannot get the macro to run. I am not very familiar with
macros so please ebar with me. In the explanation below it seems like I just
copy and paste the code as per the instructions, but when I do that my page
numbers just sit thwere staring at me with the old stagnant numbers.

Can someone shed some light in the process?

"Bob Phillips" wrote:

Mike,

Try this code

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Sh.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike Allen" wrote in message
...
I am trying to rename a worksheet by using a defined field (cell).

Example,
if I type in Dave Wilson in cell A1, is there a way to define the

worksheet
as Dave Wilson, without manually changing it everytime? And as I cahnge
names, the worksheet names will change also...Thanks in advance for your

time.
Mike allen




  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Renaming worksheets

This is change event code.

Nothing will happen until you make a change in the value of A1 or select A1 and
F2ENTER.

Then the sheet name will become whatever is in A1.

Note: if A1 contains a formula the updated value will not trigger the change in
the sheet name

For that you would need a different type of code.

Private Sub Worksheet_Calculate()
Me.Name = Range("A1").Value
End Sub


Gord Dibben MS Excel MVP


On Sat, 20 Jan 2007 17:39:00 -0800, Jerome Humery <Jerome
wrote:

I have read almost everything on how to change sheet names per the value of a
cell, and have had no luck at all working. The code below seems perfect for
my use, but I cannot get the macro to run. I am not very familiar with
macros so please ebar with me. In the explanation below it seems like I just
copy and paste the code as per the instructions, but when I do that my page
numbers just sit thwere staring at me with the old stagnant numbers.

Can someone shed some light in the process?

"Bob Phillips" wrote:

Mike,

Try this code

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Address = "$A$1" Then
Sh.Name = Target.Value
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike Allen" wrote in message
...
I am trying to rename a worksheet by using a defined field (cell).

Example,
if I type in Dave Wilson in cell A1, is there a way to define the

worksheet
as Dave Wilson, without manually changing it everytime? And as I cahnge
names, the worksheet names will change also...Thanks in advance for your

time.
Mike allen





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
renaming copied worksheets deleting .xls] dhl Excel Worksheet Functions 2 July 11th 05 10:55 PM
Merge Worksheets Mark Jackson Excel Discussion (Misc queries) 1 June 9th 05 10:39 AM
Renaming File Removes Worksheets Dustin D. Cook Excel Discussion (Misc queries) 2 April 7th 05 10:21 PM
Renaming Worksheets Steve Walford Excel Worksheet Functions 3 April 1st 05 09:29 PM
HELP! How do you--> Lock a set of rows but also link worksheets to FRUSTRATED Excel Discussion (Misc queries) 6 December 29th 04 10:05 PM


All times are GMT +1. The time now is 06:50 AM.

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"