ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Excel Worksheet Names (https://www.excelbanter.com/excel-worksheet-functions/139612-excel-worksheet-names.html)

[email protected]

Excel Worksheet Names
 
Does anyone know how to name a worksheet based on a row in a specific
worksheet. I have a listing of about 300 items and I need to create a
worksheet for each of these items.


Bob Phillips

Excel Worksheet Names
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Me.Name = .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

(there's no email, no snail mail, but somewhere should be gmail in my addy)

wrote in message
ups.com...
Does anyone know how to name a worksheet based on a row in a specific
worksheet. I have a listing of about 300 items and I need to create a
worksheet for each of these items.




Gord Dibben

Excel Worksheet Names
 
You don't have the sheets created yet and you want to create a new sheet for
each name in a range?

You say your "row" has about 300 items.

Are you using Excel 2007?

If not, the maximum items in a row can be 256.

This macro will create a new sheet for each name in row 1 from A1:IV1 in Sheet1

If using 2007, expand the range to suit.

Sub Add_Sheets22()
Dim rCell As Range
For Each rCell In Sheets("Sheet1").Range("A1:IV1")
With Worksheets.Add(After:=Worksheets(Worksheets.Count) )
.Name = rCell.Value
End With
Next rCell
End Sub


Gord Dibben MS Excel MVP

On 19 Apr 2007 06:49:45 -0700, wrote:

Does anyone know how to name a worksheet based on a row in a specific
worksheet. I have a listing of about 300 items and I need to create a
worksheet for each of these items.




All times are GMT +1. The time now is 03:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com