Avatar of gisvpn
Flag for United States of America asked on

Create new Worksheets from another worksheets (VBA)

I have a worksheet which is a template that I would like to use for other worksheets (via VBA) - hope that’s makes sense, but I will try to explain a little more.

I have two worksheets in my spreadsheet. One is called data and the other called template. The data worksheet has a load of data which details some projects and their status and the template is a formatted worksheet (to look nice) that I would like to populate each row listed on the data worksheet with on its down tab.

In plain English this is what I would like to do :

1. Delete any worksheets (existing) which are not called data or template
2. Create a new tab (with the new worksheet being a copy of the worksheet called template) for each row in the data worksheet and name it with the value in column AH for that row.
3. Copy data from the data spreadsheet for that project into the worksheet created for that project (based off of the value in cell AH (which is the project name) e.g. copy value in column Z for that row in data worksheet into C21 of the worksheet of the worksheet created for that project.. etc.. there will be about 30 values copied across.

If someone could give me a head start on the basics above that would be great!.

Thanks for any help in advance.
Microsoft ExcelMicrosoft OfficeVB Script

Avatar of undefined
Last Comment
Patrick Matthews

8/22/2022 - Mon
Patrick Matthews

A sample file showing some input as well as expected output based on that input would be helpful :)

hey matthewspatrick - Hope the attached helps.

In the example attached I would be looking for each row on the Data worksheet have a new tab created named by the name of the Sponsor listed in column B of the data worksheet.

Using the template in the template worksheet I would like the contents of the each new worksheet to be  a copy of the template worksheet and have the data populated into it with the information from the data worksheet for that row.

I have created an example worksheet in the spreadsheet attached called Peter James  which shows what I am trying to create ;)

Dont worry about the colour of the red cell (it just has a conditional formatting condition on it - copied from the template worksheet.

Hope this is clearer, however If I have not made myself clear please just ask!


Patrick Matthews

No attachment :)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

attached here ;)
Patrick Matthews

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Hi matthewspatrick,

This is a great example, thank you for the code.

Could I ask for one addition. In excel the max length of a worksheet name is 31 characters. How can I add when it names the sheet (.Name = arr(r, 1)) to only use the first 31 characters of  r,1 value so it can name the sheet successfully in all cases ;)?


Patrick Matthews


           .Name = arr(r, 1)


           Left(.Name = arr(r, 1), 31)
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

hey matthewspatrick,

I get syntax error ;)?
Patrick Matthews

.Name = Left(arr(r, 1), 31)