Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have this code, which adds sheets to a workbook based on a named
range. It renames the sheets to the name in the range, but errors on the second name change because it already exists. How do I get he macro to rename sheets based on the names in the named list. TIA Sub AddRangeOfSheets() Dim c As Range For Each c In Sheets("sheet1").Range("SList") If Not IsEmpty(c) Then CreateSheet (c.Value) End If Next c End Sub Sub CreateSheet(ShName As String) Dim CreateSheet As Worksheet On Error GoTo errh Set CreateSheet = ActiveWorkbook.Worksheets(ShName) Exit Sub errh: Set CreateSheet = ActiveWorkbook.Worksheets.Add CreateSheet.Name = ShName End Sub Thanks, Greg |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
(Complex) Loop within loop to create worksheets | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming |