[Solved] Auto-filling data into a table when new sheets are added to the workbook

PJR

New member
Hi all
First, a little context:
Every month I receive a number of samples from a supplier, which I will then carry out a few tests on. I collect all the data into a single workbook, with each batch having it's own sheet within that workbook, and an index table/sheet displaying some of the key data from each sheet.

When new sheets are added, they are created from a copy of a blank form, so the data will always be in the same locations on the sheets

The table collects data from several locations on the target sheet, often using CONCATENATE to show 2 or more values in the same cell.
At the moment I have to manually re-enter each formula (or copy/paste, changing the sheet name(s) with Replace). The first column of the sheet gives the batch no. which is then hyperlinked to the sheet in question.
What I would like to know is how can I get all these formulas to automatically change to new sheet names as they are added?

Thanks in advance
 
Hello PJR,
Welcome to ExcelDemy Forum. I understand that you have a table to extract information from each sheet of the table and you want to avoid manually re-entering the formula with a different sheet name while extracting information from a newly added sheet.

We can execute this by listing sheet names in a range of cells and using these cell references in the INDIRECT function.​

For example, let’s assume we have the following blank form.

tpVGkcAKxXBQhCv3y8wjMl7QpDHW5T0zSbJDXfVWUYJCa--Ftguk3IFJs9ceW5IFjbp1aA2wOdiubTIL5DcONc-ydEPAA9qVshPMW8oGY_1XxXGczbMua22zXcwyW0QK3cQuyedCtO8X42e2GY620n0

We have copied this form to the Sept001 sheet to create the dataset for batch numbers Sept001 and Sept002.​

rPik8TLzy6bZvX-RuN9auid6OvTLQch4uqmitEUB0v9myGurEUoYB4TMBWnxQBQxZAwt1_qbxdf9_cmjlNM9tyabKH406XAlvnL1lKs4eryJM7Dg4iH3vL3BhZCQZ7SpHwQ8ZY5O7cmxHGMSiQDTzcI

In the Index Sheet, we want to extract the Supplier Name, Temperature, Humidity, Visual Inspection Result, and Actual Testing Result for Sample Number 1.​

4iRtLjnqDaYpq1kDXnt5fNHtDSlSarQezKEfqAoY23v_Ag2YGhe2ihjQqIkyeW87UBn1Nf8FRUN7ef8SlgmW92QmuUzRewrTH2cpbRoK6WgWBoSP4oyheqGymA6q4u1GKrllmOXGJ9memv9weiiHyVQ

Manually insert the sheet name Sept001 in cell A2 and type in the following formula in cell B2 for Supplier & Sample.​

=TEXTJOIN(", ", TRUE, INDIRECT("'" & A2 & "'!B2:C2"))

Y2LMZcuMRgSGqFWZrp_R3qAa5ngMZXbR2h1aN7F2mxitb68bS1LhuxeJJS68JxXlTwBcDwTh24Q0ZTm_ZYwzGv801pQtjwSOVYpJ6pTjUjkSG4QXgtVGm9lawY_tRRbV1ZSXh6XF6DBysy31GB1a0VY

Similarly, for cell C2 insert the following formula:

=TEXTJOIN(", ", TRUE, INDIRECT("'" & A2 & "'!F2:G2"))

And, for cell D2, type in the following formula:

=TEXTJOIN(", ", TRUE, INDIRECT("'" & A2 & "'!H2:I2"))

3KnHal9yn3kpW1dp4kLPKQ1V1_QjWdOu-OGZRpbUNWCrkmACV6pSzsI90YmB6pdK0KUVq81fhZ5oddVhQcYJVOlen83mzNQXGlYBilDgjZRegrrw07-yTN195yXwPJlp_e7c13okK3ihbSHQMMXdwkQ

Here, the TEXTJOIN function concatenates the elements of the cells referenced by the INDIRECT function.

Now for extracting information from the Sept002 sheet, manually enter the sheet name in cell A3 >> select the range B2: D2 and hover your mouse pointer over the right side of cell D2 >> when the Fill Handle icon appears, drag it down.​

Vo6wtZTXTE2bKmi5aiPabQK2e4pxzoqrSXOe40ipfF4iOEHsZkZsslFvoKpFT_6gg57Mo8hrG6RiJs7VntbLZzh0MyGLSImdNFKc9xGcmmtiD_TGhMsnLKdEdxgkBuAOUTHJarlZyPu4lOw9OmzdhFg

Thus we can extract similar information for each sheet without manually re-entering the formula for each sheet.​

rFbeOjjqWt8bIUWdF8hv4WBRblXQQ0pac_NadC9cxgo460LbTmQtpNOquz9oOlTygGWHMP5V0dw-MCwXoWlUGW0UN2mpIKLGS2jQoxTFhy0OHHglO9ZdTARa1SaO_7RMo472OREWVUEymv-xfqj7HlY

Now, let’s assume we added another sheet for a new batch Sept003.​

Ra1jRZoVNEGW5HJ35_KtMkDyEbhvhoymCGdAD0Aq6ooNJGyEDn8JcW6YCIinndtxZkeIci0YS3QaqOBawu23tcxqyZxEtYqmbbd4dDEh7e1gRiivH8SkGVO2u7u67Dr_P7Ih_iBv16BdQyZ5u5nazfg

In the index Sheet, manually enter the sheet name in cell A4 >> select the range B3: D3 and hover your mouse pointer over the right side of cell D3 >> when the Fill Handle icon appears, drag it down.​

zumXAzkL-AtWv4Z0FxLR007ftq4oW6yy53xKurHk7AauAgoRs_V_irr-tP5KUzzaDEwcLExtQk8TMyjVI3f0RQp1K2ewAVfjlK0PRyVekmTvVb50UNvswfa6sRHyrDehUYVsfgu4LzczMTrgY2l7YXs

All the required information will appear without any need to change in formulas.​

utxs6gFbcexdVwYRXnua8GCsXIxhxJB45F8em0go3WgH7oZ853ciAOLVbsih-Dvlus2HFsi2rRsjSLKgjj7nT05uYgGmeOj4H2LNkGtZ98fdBa9lEEIy0eaNC14NZlpOP4tpkzJigRJADFUz7zagg0g

However, if you want to avoid manually entering sheet names and dragging Fill Handle icons, then you need a VBA macro to automatically add sheet names and extract the required information from those sheets.

I hope I was able to provide you with an idea of how to extract data from other sheets without changing the formulas for each sheet name. Let us know your feedback. The workbook used for this solution is attached below.​

Regards,
Seemanto Saha
ExcelDemy
 

Attachments

  • Auto-Filling Data When New Sheets Are Added.xlsx
    15.1 KB · Views: 0
Thank you so much, that looks amazing!
I'll be trying it out on the actual table later this week, but your explanations seem very straight forward, so I can't see there will be too many issues.

Thanks once again!
PJR
 
I can confirm the formulas worked perfectly on the copy of the workbook on my laptop at home (running 365), however when I tried it at work, they failed because my workstation is only running Excel 2016, and doesn't have the TEXTJOIN function, is there any easy work around?

One follow up question, (and using your example workbook to explain) do the Sheet names have to be exactly as written in the Batch Name field, as the batches of samples I receive usually have "/" dividers (for example, a typical batch number might read as 'L123456/7/8') which are not accepted as useable characters?
 
Dear PJR,
Thanks for your feedback. Yes, you are right. The TEXTJOIN function isn't available in Excel 2016. In that case, we can use the CONCAT or CONCATENATE function. Here, I will use the CONCAT function.

The modified formula for Cell B1 is:

=CONCAT(INDIRECT("'" & A2 & "'!B2"),", ",INDIRECT("'" & A2 & "'!C2"))

FQ - 234 - 11.png


One limitation of the CONCAT or CONCATENATE function is that these functions don't have a delimiter argument. So, we have to insert delimiters between each cell reference.

And the Sheet name doesn't have to be the same as the batch name. As you previously said each batch has its own worksheet, I assumed the worksheet names are equal to batch names. My "Batch Name" column header might have confused you as well. Sorry for that. In column A, you just have to enter the sheet name from which you want to extract data.​

FQ - 234 - 12.png

The workbook with modified formulas is attached below.

Regards,
Seemanto Saha
ExcelDemy​
 

Attachments

  • Auto-Filling Data When New Sheets Are Added.xlsx
    14.9 KB · Views: 0

Online statistics

Members online
1
Guests online
25
Total visitors
26

Forum statistics

Threads
303
Messages
1,331
Members
550
Latest member
JasonRip
Top