Automating Data Collection Across Non-Sequentially-Named Sheets and Workbooks

%3CLINGO-SUB%20id%3D%22lingo-sub-2774884%22%20slang%3D%22en-US%22%3EAutomating%20Data%20Collection%20Across%20Non-Sequentially-Named%20Sheets%20and%20Workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2774884%22%20slang%3D%22en-US%22%3E%3CP%3EI%20just%20had%20a%20project%20dropped%20in%20my%20lap%20that%20is%20a%20classic%20conflict%20between%20human-readable%20and%20machine-readable%20formats.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20need%20to%20collect%20data%20across%20hundreds%20of%20sheets%20that%20were%20designed%20to%20be%20human-readable.%20So%20that%20means%20uniquely%20named%20sheets%20(DavidJackson%2C%20JohnDoe%2C%20MissyRivers%2C%20etc.)%20and%20multiple%20small%20tables%20within%20them.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EThankfully%2C%20each%20sheet%20is%20formatted%20in%20exactly%20the%20same%20way.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EIs%20there%20a%20way%20to%20build%20a%20summary%20table%20that%20can%20automate%20referencing%20certain%20cells%20(ex.%20%3DDavidJackson!B2%2C%20%3DJohnDoe!B2%2C%20%3DMissyRivers!B2)%20in%20order%2C%20without%20needing%20to%20track%20down%20and%20type%20each%20sheet%20name%20sequentially%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AnachronisticJam_1-1632327106502.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F312104i709DC6A63362648C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AnachronisticJam_1-1632327106502.png%22%20alt%3D%22AnachronisticJam_1-1632327106502.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2774884%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2775080%22%20slang%3D%22en-US%22%3ERe%3A%20Automating%20Data%20Collection%20Across%20Non-Sequentially-Named%20Sheets%20and%20Workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2775080%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1163570%22%20target%3D%22_blank%22%3E%40AnachronisticJam%3C%2FA%3E%26nbsp%3B%20so%20assuming%20a%20couple%20things%20these%20formulas%20might%20help%20you.%3C%2FP%3E%3CP%3Ea)%20you%20need%20the%20sheet%20name%20to%20be%20added%20to%20each%20sheet.%26nbsp%3B%20so%20let's%20pretend%20cell%20A1%20is%20available%20then%20add%20this%20formula%20there%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DLET(path%2CCELL(%22filename%22%2CA1)%2CRIGHT(path%2CLEN(path)-SEARCH(%22%5D%22%2Cpath)))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Eb)%20you%20can%20then%20create%20the%20list%20of%20all%20sheet%20names%20using%20this%20formula%20which%20only%20requires%20you%20to%20enter%20the%20first%20and%20last%20sheet%20names%20and%20the%20cell%20from%20a)%20above%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DLET(sref%2CSheet1%3ASheet5!A1%2CTRIM(MID(TEXTJOIN(REPT(%22%20%22%2C100)%2C%2Csref)%2CSEQUENCE(COUNTA(sref)%2C%2C1%2C100)%2C100)))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3Bc)%20you%20can%20then%20create%20the%20remaining%20lookup%20values%20using%20INDIRECT()%20combining%20the%20sheet%20name%20from%20b)%20with%20the%20absolute%20cell%20reference%20you%20need%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2775367%22%20slang%3D%22en-US%22%3ERe%3A%20Automating%20Data%20Collection%20Across%20Non-Sequentially-Named%20Sheets%20and%20Workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2775367%22%20slang%3D%22en-US%22%3EI%20just%20wanted%20to%20add%20a%20note%20with%20encouragement%20to%20modify%20altogether%20the%20way%20the%20workbook%20is%20structured.%20You're%20so%20right%20that%20it%20was%20created%20to%20be%20%22user-friendly%22%20and%20in%20the%20process%20actually%20interferes%20with%20letting%20Excel%20do%20what%20it%20excels%20at.%3CBR%20%2F%3EWhat%20you%20want%2C%20longer%20term%2C%20is%20at%20the%20most%20one%20sheet%20representing%20whatever%20it%20is%20in%20each%20%22small%20table%22%20simply%20adding%20a%20column%20to%20differentiate%20data%20re%20JohnDoe%20from%20that%20of%20MIssyRIvers%2C%20etc.%3CBR%20%2F%3E%3CBR%20%2F%3EEven%20better%2C%20unless%20those%20tables%20are%20widely%20differing%20in%20their%20content%2C%20is%20to%20create%20a%20single%20table%20with%20all%20the%20data.%20Excel%20is%20really%20good%20at%20parsing%20apart%20a%20single%20database.%3CBR%20%2F%3E%3CBR%20%2F%3E(This%20from%20a%20person%20who%20was%20director%20of%20the%20HR%20%26amp%3B%20Payroll%20database%20for%20a%20major%20corporation%20during%20my%20working%20career.)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2775451%22%20slang%3D%22en-US%22%3ERe%3A%20Automating%20Data%20Collection%20Across%20Non-Sequentially-Named%20Sheets%20and%20Workbooks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2775451%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3Bunfortunately%2C%20I%20didn't%20have%20any%20control%20over%20the%20design%20or%20collection%20stages%20of%20the%20project%20or%20this%20could%20have%20been%20avoided%20at%20the%20start.%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EAt%20this%20point%20going%20back%20and%20rebuilding%20everything%20is%20well%20outside%20of%20scope%20for%20the%20project%2C%20so%20I%20have%20to%20make%20the%20best%20of%20what%20I've%20got.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I just had a project dropped in my lap that is a classic conflict between human-readable and machine-readable formats. 

I need to collect data across hundreds of sheets that were designed to be human-readable. So that means uniquely named sheets (DavidJackson, JohnDoe, MissyRivers, etc.) and multiple small tables within them. 

Thankfully, each sheet is formatted in exactly the same way.


Is there a way to build a summary table that can automate referencing certain cells (ex. =DavidJackson!B2, =JohnDoe!B2, =MissyRivers!B2) in order, without needing to track down and type each sheet name sequentially?

 

AnachronisticJam_1-1632327106502.png

 

5 Replies

@AnachronisticJam  so assuming a couple things these formulas might help you.

a) you need the sheet name to be added to each sheet.  so let's pretend cell A1 is available then add this formula there:

=LET(path,CELL("filename",A1),RIGHT(path,LEN(path)-SEARCH("]",path)))

b) you can then create the list of all sheet names using this formula which only requires you to enter the first and last sheet names and the cell from a) above:

=LET(sref,Sheet1:Sheet5!A1,TRIM(MID(TEXTJOIN(REPT(" ",100),,sref),SEQUENCE(COUNTA(sref),,1,100),100)))

 c) you can then create the remaining lookup values using INDIRECT() combining the sheet name from b) with the absolute cell reference you need

 

I just wanted to add a note with encouragement to modify altogether the way the workbook is structured. You're so right that it was created to be "user-friendly" and in the process actually interferes with letting Excel do what it excels at.
What you want, longer term, is at the most one sheet representing whatever it is in each "small table" simply adding a column to differentiate data re JohnDoe from that of MIssyRIvers, etc.

Even better, unless those tables are widely differing in their content, is to create a single table with all the data. Excel is really good at parsing apart a single database.

(This from a person who was director of the HR & Payroll database for a major corporation during my working career.)

@mathetes unfortunately, I didn't have any control over the design or collection stages of the project or this could have been avoided at the start. 

At this point going back and rebuilding everything is well outside of scope for the project, so I have to make the best of what I've got.

BTW in case you aren't aware, if you highlight multiple sheets (e.g. all the sheets) and then type a value or formula into a cell, that value or formula is placed in EVERYONE of the sheets highlighted. Basically to do step a) in my comment you can highlight all the sheets (i.e. click first sheet tab, then scroll to end and shift-click the last sheet tab) and paste that formula into whichever cell is 'available'.

To 'unselect' the range of sheets you can either select a previous unselected sheet or ctrl-click any sheet to unselect it and then click on that sheet.

Then in step b) just update that first part of the formula with the correct starting and ending sheet names and instead of A1 put which ever cell you pasted that formula from a) into.

@AnachronisticJam 

 

Let me add, then, in addition to the suggestions you've gotten from @mtarler , that you look into the INDIRECT function. I use that on one of my more ambitious workbooks (dealing with investing in various issues) where I use a formula like this

=INDIRECT($B5)&"!"&A$1) 

to refer to the sheet with the name found in B5  (column B contains a list of sheet names of other sheets in the workbook)

and A$1 refers to a specific cell in whatever sheet is named by B5.

 

That formula, with its absolute and relative references is used to populate a summary sheet built from individual sheets that, like yours, have common data in the same cells. In your case, this would require a one-time effort (perhaps a macro?) to create in the Summary sheet a column with each sheet's name.

 

I'm attaching a copy of a sample of that workbook. The "Current Summary" sheet is the one that uses INDIRECT

 

Here, too, is a good website for further info on using INDIRECT. https://exceljet.net/excel-functions/excel-indirect-function