1. HOW TO BUILD A DOCUMENT REPOSITORY WITH EXCEL
Michael Brothers
In 2016 I builta documentrepositoryfora manufacturingclientinDanvers,Massachusetts.The companyproduces
bioreactorassembliesmade fromalotof plastictubingandparts.On a regularbasiscustomerswouldrequesta
certificate of animal origin,allergens,etc.inthe material composition,whichnecessarilytracedbackto supplier
components.Myrole wasto collectall of the suppliercertificatesinacentral serverlocation,andmake themeasily
retrievable.
Imagine acompanythat makesfabricdolls.They make all differentshapesandsizesof doll,butthe raw materialsare
typicallyfabric,yarn,thread,stuffingandbuttons.Sowe have five suppliers(FabricCo,YarnCo,etc.) andeachsupplier
offersdozensof variationsof theirproduct.Eachdoll thatthe companyproduceswill have aBill of Materialsspecificto
that doll – a particularcut of fabric,a certaincolor yarn,etc.
Whena customerordersa doll,theyaskif the doll containspeanutsorlatex.Anothercustomerasksaboutbovine
tallow.A thirdhas carbonfootprintconcerns.Inresponse,ourcompanydevelopsaMaterial of CompositionCertificate
(we’ll call itaMOCC) that theysendtoall theirsuppliers.The MOCCasksa setof questionsthataddressthe dozenorso
mostcommon customerconcerns. Overthe years,the MOCC haschangedto addressnewerdemands.Soinourfile
systemwe have three versionsof the MOCCform;MOCC1, MOCC2 and MOCC3. Theyare similarexceptthatthe order
of the questionsisdifferentineachform,andMOCC3 askstwo new questionsthatare noton MOCC1 or MOCC2.
So howdo we buildasystemthat allowsustotake a doll’sBill of Materials,andautomaticallyanswerquestionsbased
on supplierMOCCforms? The followingsectionsoutline mysolutiontothe problem.
Step 1: File Folders.....................................................................................................................................................2
Step 2: Part Number Worksheet.................................................................................................................................2
Step 3: Hyperlinks......................................................................................................................................................2
Step 4: Questionnaire Fields.......................................................................................................................................3
Step 5: Conditional Formatting...................................................................................................................................4
Step 6: Performing Lookups........................................................................................................................................5
Step 7: Simplify Matters with a Macro ........................................................................................................................6
2. Step 1: File Folders
Each supplierisassignedafolderonthe networkdrive.Supplierfoldersholdthreesubfolders;“FormsSent”,“Forms
Current”and “FormsOutdated”. Inthe data collectionphase of the project,all supplierformsare scannedaspdf files
and putintothe appropriate folder.
Suppliers
FabricCo
FormsCurrent
GGparts signed.pdf
FormsOutdated
FormsSent
GGparts.pdf
ThreadCo
YarnCo
Step 2: Part NumberWorksheet
The nextstepisto create a spreadsheettoholdindividual components,eachwithaunique partnumber:
The firstthree rowsare intentionallyleftblank –thiswill helpaddressthe differentMOCCversionslateron.
Step 3: Hyperlinks
Assume we have MOCCformsfor everypart.The easysolutionistoadda hyperlinktothe partnumbercell thatpoints
to the properfile.DON’T!Ifoundoutthe hard way that hyperlinks(like cellborders) don’ttravel whenthe spreadsheet
issorted.Instead,use the HYPERLINKfunction:
=HYPERLINK(“filepathfilename”, “text to appear in cell”)
Thisprovidesapermanentlink,andsome newoptions.
For example,inmyspreadsheetIusedthe hyperlinktoindicatewhichversionof aformwe hadon file.
If the MOCC for YarnCo’smerinowool productsisversion2,I mighthave
=HYPERLINK(“YarnCoForms%20ReceivedGGparts%20signed.pdf”,“2”)
Here, %20 standsin place of a space character – depending on youroperating systemyou may notneed it.
Thisway,I can easilyselectall partswitholderMOCCversionsandsendrequeststothe supplierforupdatedforms.
3. Step 4: Questionnaire Fields
Next,create columnsforeachquestion.Thenmapthe questionnaireversionstothe questionsusingthe thre e rows
reservedatthe top of the sheet.
Here,column E contains linkstoMOCC files,withtextindicatingwhichversionisonfile.
ColumnsFthroughJ holdanswersto surveyquestions.Note thatrightnow,these columnsare sortedbyrow3
– that is,theyappearinMOCC3 order.Before enteringabatch of MOCC2 forms,we couldsort byRow 2:
SelectcolumnsF:H,open CustomSort,unselect“Mydata has headers”,choose Options, select“Sortlefttoright”:
4. Step 5: Conditional Formatting
Take advantage of conditional formattingtohighlight“Yes”responsesincertaincategories:
Note:thisispurelycosmetic,anddoesnotaffectanyof the values.
5. Step 6: PerformingLookups
Assume thatour spreadsheetnowcontainsdozensof suppliersandthousandsof parts.It’stime to putthemto work!
Opena newtab, call itPart NumberLookup,andcreate columnsfor the categoriesyoucare about.
In the projectI completed forthe biotechfirm,the Bill of Materialswascopiedfromamanufacturingdrawinginpdf.
As such,the quantity,descriptionandpartnumberall appearedonone line.Fortunately,the partnumberwasalways
the last wordof text.The followingline of code letme stripjustthe part numberintoitsowncell:
=RIGHT(A2,LEN(A2)-FIND("|",SUBSTITUTE(A2," ","|",LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))
Thiscounts all the spacesinthe string,turnsthe lastone intoa vertical pipe,andthengrabstextto the rightof the pipe.
Usingthe VLOOKUPfunctionorINDEX/MATCHisyour choice.If usingVLOOKUP,be sure to add the FALSEargument,
while MATCHshouldinclude the 0argument.These argumentspreventfalse returnsif apartnumberisnot listed,and
don’trequire thatpart numbersbe sorted.IpreferINDEX/MATCH:
Sheet1ColumnFcorrespondstothe Peanutsquestion. Takecarenotto rearrangetheSheet1 columns!
The lookupformulawill grabdatafrom columnFno matterwhichquestionisassignedthere.
I got aroundthisby settingaside asmall group of columns overto the right of the questionnairecolumns.TheseI
devotedtokeyquestionslike peanutsandlatex.While itaddedabitto data entry,itallowedme tosort the
questionnaire columnsfreely. Italsogave me a place to record data obtained fromsourcesbesidesthe questionnaire.
Anotherworkaroundwouldbe to copythe INDEX/MATCHformulaintocell C1 – thatis, topull the columnheadingfrom
Sheet1ColumnFby matching onthe phrase “Part Number”.
6. Step 7: SimplifyMatters with a Macro
As itstands,performingalookuprequiresfirstpastingthe Bill of Materials,thenselectingthe formularowsfrom
somewhere andfinallypastingthemintothe appropriate spot.Thiscanall be done inone stepwitha VBA macro.
First,decide where youwouldlike tostore the lookupformulas.Theyshouldbe inaplace that isaccessible tothe
macro, and unlikelytobe deletedbythe user.Ikeptmine ona separate tab, buthere I’ll putthemintothe first row of
the lookuptab.Aftermakingsure the macro worksproperly,I’dhide the row fromview.
Hit Alt-F11to openthe VB editorinExcel,openanew module,andtype the followingcode:
Sub PasteBoM()
‘ First make sure the ActiveCell is in the right column
If ActiveCell.column <> 1 Then
MsgBox(“Please select a cell in Column A and try again.”
Exit Sub
End If
‘ Then make sure the neighborhood 100 rows down and 4 columns right is clear
If WorksheetFunction.CountA(Range(ActiveCell, _
ActiveCell.Offset(100,4))) > 0 Then
Box = MsgBox(“You might be pasting new data on top of old data. _
Do you wish to continue?”, vbYesNo, “DANGER: Potential Loss of Data!”)
Select Case box
Case vbNo
Exit Sub
End Select
End If
‘ Paste the BoM from the clipboard, then the formulas
Selection.PasteSpecial (xlPasteAll)
Range(“b1:e1”).Copy Selection.Offset(0,1)
End Sub
I assigned“Ctrl-j”tothe macro. It shouldbe notedthatmacros cannotbe reversed –that is,Ctrl-zdoesn’twork.
That is whyI included the neighborhoodchecktoensure dataisnot unintentionallydeleted.
Conclusion
That’s it!Nowwe have an orderlyfilingsystem,apartslibrarythat pointstorelevantfiles,andameansto lookup
meaningful datafromaBill of Materials.
One final note.Inthe Lookupsection,INDEX/MATCHbroughtoverthe cell value –that is,the “Yes” or “No”.
If I’d wantedtosee the file pathinstead,Iwouldhave tolookinside the HYPERLINKfunction.
Say that the parts spreadsheethadthe followingentryincolumnEforpart numberGG1468:
=HYPERLINK("SuppliersFabricCoForms CurrentGGparts signed.pdf","2")
The file pathcan be obtainedwithtwoformulas:
=FORMULATEXT(INDEX(Sheet1!E:E,MATCH($B2,Sheet1!$A:$A,0)))
Returns
=HYPERLINK("SuppliersFabricCoFormsCurrentGGpartssigned.pdf","2")
So then
=MID(F2,13,LEN(F2)-18)
Returns
SuppliersFabricCoFormsCurrentGGpartssigned.pdf
Voila!