Tying a Sheet Name to a Cell within a Macro

saschmeling

New Member
Joined
Jun 27, 2012
Messages
39
Hi All,

I saw the earlier post of tying a sheet name to a Cell but I am creating a Macro that will take data and split it into 7 separate workbooks then take the data that is split and create new sheets that will sum up the data and add pivot tables to the data.

This will all be done automatically- so What I am really looking for is a bit of code that I can place into an existing Macro with a Loop to tie the sheet names to a cell. This is a Macro that is being stored at the Personal Macro Workbook level.

Does anyone have any ideas or suggestions?

Thanks,
Scott
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
ActiveCell.FormulaR1C1 = _
"=RIGHT(CELL(""filename"",R[-32]C[-50]),LEN(CELL(""filename"",R[-32]C[-50]))-FIND(""]"",CELL(""filename"",R[-32]C[-50]),1))"

will put the sheet name in AY33, for example
 
Upvote 0
ActiveCell.FormulaR1C1 = _
"=RIGHT(CELL(""filename"",R[-32]C[-50]),LEN(CELL(""filename"",R[-32]C[-50]))-FIND(""]"",CELL(""filename"",R[-32]C[-50]),1))"

will put the sheet name in AY33, for example

Thanks, But that is the reverse of what I am trying to do. I want to have the sheet name match what is in a cell. So if Cell A1 states "Adults" I want the sheet tab to change from "Sheet 1" to "Adults".

Hope that makes it more clear.
 
Upvote 0
Try this.
Code:
For Each ws In ThisWorkbook.Worksheets
     ws.Name = ws.Range("A1").Value
Next ws
 
Upvote 0
Hi Norie,

Is there a way to make this so that each sheet can reference a different cell address. So Sheet1 references Cell A7, Sheet2 references Cell A1, Sheet3 references Cell A1.

Thanks,
Scott
 
Upvote 0
Scott

You would need a way for the code to know which cell in which sheet to use for the name.
 
Upvote 0

Forum statistics

Threads
1,214,988
Messages
6,122,620
Members
449,092
Latest member
amyap

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