VBA - How add worksheet with specified name?

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi,

what about if you want to add multiple worksheets and the names are coming from a list/range?

Hi,

After the answer to that question, what question comes next?
Formulate the beginning what you want, do not ask question after question!
 
Upvote 0
Hi Ingolf,

the code above can rename a single worksheet and its working perfectly fine. however, i'm working on workbook with multiple worksheets that need to be renamed... Do you know a code that can rename sheets based on name list or cell value?

Hi,

After the answer to that question, what question comes next?
Formulate the beginning what you want, do not ask question after question!
 
Upvote 0
Hi,

Name of sheets to be created, are in column A starting with A2, and the sheet is called List.
Obviously you can change the column or sheet name.

Code:
Sub CreateSheets() 
     
    Dim ws As Worksheet 
    Dim Ki As Range 
    Dim ListSh As Range 
     
    With Worksheets("List") 
        Set ListSh = .Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row) 
    End With 
     
    On Error Resume Next 
    For Each Ki In ListSh 
        If Len(Trim(Ki.Value)) > 0  Then 
            If Len(Worksheets(Ki.Value).Name) = 0 Then 
                Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = Ki.Value 
            End If 
        End If 
    Next Ki 
     
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top