View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Creating worksheets with cell values as names

Hi Bob,

With your names listed in column A , starting in A2 (to allow for a header),
try:

Sub AddSheets()
Dim LastCell As Range, Rng As Range, Cell As Range
Dim WS As Worksheet
Set WS = ActiveSheet
Set LastCell = WS.Cells(Rows.Count, "A").End(xlUp)
Set Rng = WS.Range("A1", LastCell)
For Each Cell In Rng
If Not IsEmpty(Cell) Then
Sheets.Add.Name = Cell.Value
End If
Next

End Sub



---
Regards,
Norman


"Bob" wrote in message
...
Hello

From a group of cells in a worksheet I want to create
worksheets in the same workbook, each of which has the
name of the contents of the cells (all strings).

for example:
value in cell A1 is 'Ball Valve'
valve in cell A2 is 'Globe Valve'

I want to create 2 worksheets: one named 'Ball Valve', the
other 'Globe Valve'.

The number of cells will vary as will the values. The
group will always start in cell A1.

I can add 2 worksheets, but they have the generic
names 'Sheet2' etc.

What is the best way of creating the worksheets and
renaming them?