Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to create a work book containing 52 sheets, with the first being named week 1, then week 2 and so on. How can I do this without renaming each sheet manually.

Thankyou

share|improve this question

1 Answer 1

I don't see any restrictions on how to achieve this, so I've used VBA code:

Sub btnClick()
    Dim counter As Integer
    counter = 1
    For Each ws In ActiveWorkbook.Worksheets
        ws.Name = "Week" & counter
        counter = counter + 1
    Next
    Do While counter < 53
        Worksheets.Add().Name = "Week" & counter
        counter = counter + 1
    Loop
End Sub

What this does is renaming the existing worksheets: so if you use a new workbook, you will have 3 worksheets and those will be renamed to week1, week2 and week3. When the existing worksheets are renamed, the code will generate new worksheets and name them "week" with the number of the worksheet.

If you have any more features or trouble with this solution, feel free to comment.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.