Macro To Name Sheets Based On Cell Range

tjeacret

New Member
Joined
Oct 22, 2010
Messages
22
Hello! This is my first post but I have used this site many times in the past. I have a question I need help with. I have an excel workbook that I need a macro to name the sheets based on cell ranges. Here is what I need:

Name sheet4-sheet18 based on cell range sheet1 B4:B18

Thanks!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Put this code together to do what you are asking:
Code:
Sub SortFruit()
Set Rng = Sheets("Sheet1").Range("B4:B18")
    'Assign variables
    sn = ActiveSheet.Index
    i = 1
    'Cycle thru Range Text
    For Each c In Rng
        Worksheets(sn + i).Name = c.Value
        i = i + 1
    Next c
End Sub
The code will name the worksheet to the right of the active worksheet.
Code assumes you have Text in cells B4:B18 that is proper for naming a worksheet. It also assumes you have the proper number of worksheet.
 
Upvote 0

Forum statistics

Threads
1,224,541
Messages
6,179,418
Members
452,912
Latest member
alicemil

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