Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Assign Macro to cell???

Place this in the Thisworkbook module Ric

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Address = "$A$1" Then
If Target.Value < "" Then
On Error Resume Next
ActiveSheet.Name = Target.Value
On Error GoTo 0
End If
End If
End Sub

If you change A1 in each sheet the tab name will change to the cell value



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ric" wrote in message ...
I want to run a macro in excel, such that when a name is typed into a cell
and Return pressed the name becomes the sheet name...

I have used: ActiveSheet.name = ActiveCell.value to do the naming

Ideally this would work with the down arrow or tab as well - or even better,
whenever the cell 'loses focus'.

I hope this is as blindingly simple as I feel it should be...

Thanks in advance

Ric




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Assign Macro to cell???

This is the standard defintion for the event. When you select the event
from the module dropdowns at the top (workbook object in left dropdown,
SheetChange in right dropdown) this is what is entered (if you can't select
it, you are in the wrong module).

the Sh argument holds a reference to the worksheet that contains the range
(target) that triggered the event.

--
Regards,
Tom Ogilvy


"Ric" wrote in message
...
Ron

That's brilliant - thanks very much!

I can see how it all works except one thing: What does "ByVal Sh As

Object"
do?

Thanks again

Ric

"Ron de Bruin" wrote in message
...
Place this in the Thisworkbook module Ric

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

Range)
If Target.Address = "$A$1" Then
If Target.Value < "" Then
On Error Resume Next
ActiveSheet.Name = Target.Value
On Error GoTo 0
End If
End If
End Sub

If you change A1 in each sheet the tab name will change to the cell

value



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ric" wrote in message

...
I want to run a macro in excel, such that when a name is typed into a

cell
and Return pressed the name becomes the sheet name...

I have used: ActiveSheet.name = ActiveCell.value to do the naming

Ideally this would work with the down arrow or tab as well - or even

better,
whenever the cell 'loses focus'.

I hope this is as blindingly simple as I feel it should be...

Thanks in advance

Ric








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
Assign Macro to a Cell Bob Myers Excel Worksheet Functions 2 December 14th 09 07:35 PM
Formula or Macro to Assign Cell Locations econWGR Excel Discussion (Misc queries) 1 February 16th 07 02:57 AM
assign macro PH NEWS Excel Worksheet Functions 2 February 28th 06 02:17 PM
Assign a Macro Pendelfin Excel Discussion (Misc queries) 1 January 10th 06 11:35 PM
How to assign a macro Mike Excel Discussion (Misc queries) 4 July 5th 05 06:43 AM


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