Macro, change the name of the worksheet with the value of a cell

dfino77

New Member
Joined
Aug 23, 2011
Messages
2
Hi Everyone!

I need some help.

I need to create a macro with this step:

1. Select a cell (A5) for one worksheet (sheet 1)
2. Add a new worksheet (sheet 2)
3. Change the name of the new worksheet (sheet 2) with the value of the cell (E2) of this worksheet (sheet 2)
4. Go to the worksheet (sheet 1) cell (A6) and repeat all the step until the cell of the worksheet (sheet 1) is empty.

How can i do it??
Thanks in advance for your help
Kind Regards
Dfino
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
"4. Go to the worksheet (sheet 1) cell (A6) and repeat all the step until the cell of the worksheet (sheet 1) is empty."

There is a problem. When step 3 is repeated, there will be an error since only one sheet can have the tab name of the entry in A2.

Also, what do you want to happen if A2 has an illegal sheet name?
 
Upvote 0
i hope if this code will help you
Code:
Sub Test()
Dim c As Range, LR As Long
LR = Range("a" & Rows.Count).End(xlUp).Row
For Each c In Range("A5:A" & LR)
    Sheets.Add(after:=Sheets(Sheets.Count)).Name = c.Value
Next c
End Sub
 
Upvote 0
Hi!!

Thanks for the answes, however the macro does not work.:(

The new sheet always has a different name, because the value of the cell E2 change.

Thanks!!
 
Upvote 0
It sounds like you have a list of names in column E (starting with row 2).
And for each of those names, you want a sheet added to the workbook and named accordingly.

What I don't understand is where column A comes in, why A5 goes with E2 and which cell goes with A6.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,253
Members
452,900
Latest member
LisaGo

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