Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Making name of worksheet a function

sheetHi everyone,

I was wondering if there is any way to have the name of a worksheet change
as a function of an entry in a specific cell. The sheets themselves are
created manually.

Specifically, I have a data entry sheet where the names (ie locations) of
some new branches are entered once. Then each location has a sheet, which now
carries the (fixed) branch code. But for more clarity, the customer would
prefer to see the branch names here without having to enter them in each
sheet name again.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Making name of worksheet a function

This assumes you have a worksheet with a list of names in column A. If you
enter a name in column A, this macro will create a new worksheet with the
name just entered.

If an old name is re-entered, a warning is issued. Insert this event macro
in the worksheet code area of the worksheet with the list:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim a As Range, sh As Worksheet, v As String, s As Worksheet
Set t = Target
Set a = Range("A:A")
Set s = ActiveSheet
If Intersect(t, a) Is Nothing Then Exit Sub
v = t.Value
For Each sh In Worksheets
If v = sh.Name Then
MsgBox ("Worksheet " & v & " already exists")
Exit Sub
End If
Next
Worksheets.Add
ActiveSheet.Name = v
s.Activate
End Sub


Because it is worksheet code, it is very easy to install and automatic to use:

1. right-click the tab name near the bottom of the Excel window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you have any concerns, first try it on a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm

--
Gary''s Student - gsnu200838


"Anna in Istanbul" wrote:

sheetHi everyone,

I was wondering if there is any way to have the name of a worksheet change
as a function of an entry in a specific cell. The sheets themselves are
created manually.

Specifically, I have a data entry sheet where the names (ie locations) of
some new branches are entered once. Then each location has a sheet, which now
carries the (fixed) branch code. But for more clarity, the customer would
prefer to see the branch names here without having to enter them in each
sheet name again.

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
Making a worksheet default Per[_2_] Excel Discussion (Misc queries) 1 March 28th 07 03:43 PM
Making formulae function throughout worksheet AngelFoxBlue Excel Worksheet Functions 1 June 19th 06 04:15 AM
Making a worksheet a templete at_a_loss Excel Discussion (Misc queries) 1 February 24th 06 07:29 PM
Making Find go through worksheet only once Frank Marousek Excel Discussion (Misc queries) 3 April 27th 05 07:40 PM
help! making a worksheet more automated? redb Excel Discussion (Misc queries) 2 April 15th 05 01:53 PM


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