Dynamically renaming sheets based on cell value with formula in each sheet

Joined
Jul 28, 2020
Messages
2
Office Version
  1. 365
Platform
  1. MacOS
Hello,

I'm hoping someone can help me with a bit of code.

I have a workbook made up of employee timesheets. One worksheet per employee. I also have one sheet named 'data' which is the full list of employee names and hours which will be copied from our rostering software.

The employees with timesheets changes every pay cycle so currently cell D4 on each timesheet has a formula in it to pull the employee name from the relevant cells in the 'data sheet'.
=Data!B2
=Data!B3
=Data!B4 ...and so on.

I want to only have timesheets that need to be processed in each pay cycle workbook document, rather than having a whole bunch of blank worksheets saved with a sheet for every employee, so it needs to be dynamic.

What I would like is for the sheet name to generate based on the name in D4 on each sheet (which is the name pulled from the 'data' sheet with the formula)
I can adjust where the data on the 'data sheet' sits to ensure cell D4 contains the name for this sheet too.

Through google I have gleaned a very basic understanding of how to use the VBA to put in the code and run the macro, but all the examples of code I found online (including in this forum) didn't work for my specific requirements. Some just didn't do anything and others identified as having bugs. I have no idea how to correctly write the code myself so I'm hoping someone can please help me out!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,608
Messages
5,765,400
Members
425,282
Latest member
Nibblesy

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
Top