Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using VB to change sheet name to match cell contents

Is there an easy way using VB to change the currently
active sheet's name to a cell value?

Scenario:
---------
I have a time reporting sheet which uses an employee
name validation pulldown to select and show work time
statistics for any of my staff.

I'd like to create a complimentary VB function which
changes the sheet's name to match that of the currently
selected employee, preferably via a changed cell action,
but I'd settle for creating a button control to accomplish
the sheet name change.

Any suggestions or code examples would be appreciated

Thx - GP
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Using VB to change sheet name to match cell contents

Hi
try
sub foo()
with activesheet
.name=.range("A1").value
end with
end sub

--
Regards
Frank Kabel
Frankfurt, Germany


Gary Paxson wrote:
Is there an easy way using VB to change the currently
active sheet's name to a cell value?

Scenario:
---------
I have a time reporting sheet which uses an employee
name validation pulldown to select and show work time
statistics for any of my staff.

I'd like to create a complimentary VB function which
changes the sheet's name to match that of the currently
selected employee, preferably via a changed cell action,
but I'd settle for creating a button control to accomplish
the sheet name change.

Any suggestions or code examples would be appreciated

Thx - GP

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using VB to change sheet name to match cell contents

This worked beautifully! Thanks Frank

-----Original Message-----
Hi
try
sub foo()
with activesheet
.name=.range("A1").value
end with
end sub

--
Regards
Frank Kabel
Frankfurt, Germany


Gary Paxson wrote:
Is there an easy way using VB to change the currently
active sheet's name to a cell value?

Scenario:
---------
I have a time reporting sheet which uses an

employee
name validation pulldown to select and show work time
statistics for any of my staff.

I'd like to create a complimentary VB function which
changes the sheet's name to match that of the currently
selected employee, preferably via a changed cell action,
but I'd settle for creating a button control to

accomplish
the sheet name change.

Any suggestions or code examples would be appreciated

Thx - GP

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Using VB to change sheet name to match cell contents

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing Then
With Target
me.name = target.value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gary Paxson" wrote in message
...
Is there an easy way using VB to change the currently
active sheet's name to a cell value?

Scenario:
---------
I have a time reporting sheet which uses an employee
name validation pulldown to select and show work time
statistics for any of my staff.

I'd like to create a complimentary VB function which
changes the sheet's name to match that of the currently
selected employee, preferably via a changed cell action,
but I'd settle for creating a button control to accomplish
the sheet name change.

Any suggestions or code examples would be appreciated

Thx - GP



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using VB to change sheet name to match cell contents

Thanks Bob - exactly what I was looking for!
-----Original Message-----
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1")) Is Nothing

Then
With Target
me.name = target.value
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs

to be
'placed in the appropriate worksheet code module, not a

standard
'code module. To do this, right-click on the sheet tab,

select
'the View Code option from the menu, and paste the code

in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Gary Paxson" wrote

in message
...
Is there an easy way using VB to change the currently
active sheet's name to a cell value?

Scenario:
---------
I have a time reporting sheet which uses an

employee
name validation pulldown to select and show work time
statistics for any of my staff.

I'd like to create a complimentary VB function which
changes the sheet's name to match that of the currently
selected employee, preferably via a changed cell action,
but I'd settle for creating a button control to

accomplish
the sheet name change.

Any suggestions or code examples would be appreciated

Thx - GP



.



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
Formula to match Cell with table of contents Terry Excel Discussion (Misc queries) 1 May 20th 10 08:15 PM
autofit cell height and width to match bitmap contents gurubox Excel Worksheet Functions 0 December 18th 08 07:06 PM
change cell contents when pull down menu choices change jb21 Excel Worksheet Functions 3 November 21st 08 10:34 PM
Edit macro to match entire cell contents nis75p06 Excel Discussion (Misc queries) 1 September 3rd 05 04:27 PM
Lookup cell contents in on sheet based on a formula in second sheet Michael Wright via OfficeKB.com Excel Worksheet Functions 1 April 30th 05 04:11 PM


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