Search multiple workbooks in a folder and subfolders for a specific string

jskasango

Board Regular
Joined
Jul 18, 2012
Messages
202
Office Version
  1. 365
Platform
  1. Windows
I need a VBA code to let me browse to a folder and Search for a specific string in multiple workbooks ((*.xl*) Sheet.Results)) in the folder and subfolders . If the specified string is found the code should copy the entire row into a new "Found" workbook including the headers from the first "Hit" only and any "new" headers in subsequent "finds" should be appended to the right of the "Found".
Any assistance will be highly appreciated. THANK YOU VERY MUCH IN ADVANCE.
 
The new wb has headers? It sounds like there can be more than 1 find per column? U didn't clarify whether the search is for the header and what "containing" and "Beginning with" has to do with the search? Dave
Sorry about that, the find is in the data area but I don’t mind having a confirmation that the headers are audited eg if header 1 is in column D in the first find and column G in the next find (in the next WB searched), the output should be in the same column in the output.
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Dave- Sending a sample WB as soon as I get to my destination. -Kasango
 
Upvote 0
Kasango.... so search for each header which may be found multiple times in each column. The same header can also be found in multiple wbs. Copy the entire row (columns 1 to last used column) and transpose it to a column (the same column for the same header) in a new wb. That's a fairly big ask. Posting a sample data wb would certainly be helpful. Dave
 
Upvote 0
about.... so search for each header which may be found multiple times in each column. The same header can also be found in multiple wbs. Copy the entire row (columns 1 to last used column) and transpose it to a column (the same column for the same header) in a new wb. That's a fairly big ask. Posting a sample data wb would certainly be helpful. Dave
Dave-Please give me abou two hours. I will do that. My objective is stack the found data.
Thanks for your patience-kasango
 
Upvote 0
Dave-Please give me abou two hours. I will do that. My objective is stack the found data.
Thanks for your patience-kasango
3WHYB-SXID21-5.xls
BCDEACADAEAFAGAHAIAJAKALAMANAOAPARAVAWAXAY
1EntryStockIDNameBreedersPedigree1GrainYieldTons_FieldWtRankNoAnthesisDateDaysToSilkASIPlantHeightCmEarHeightCmEarPositionRootLodgingPerStemLodgingPerEPPNoBadHuskCoverPerEarRotTotalPerGrayLeafSpot1_5LeafBlightTurcicum1_5GrainMoisturePerPlantStand_NumPerPlotVirusMaizeStreak1_5EarAspect1_5
2ENTSTKIDCODEPED2GYFRkADDSASIPHEHEPORLSLEPPHCERGLSETMOINPMSVEA
3NumberFormat0.0000.00.00.00.00.00.000.00.00.000.00.00.00.00.00.00.00.0
4Count90909090909090909090909090909090909090
5TrialMean7.654668.368.90.8237.2131.70.566.015.51.033.11.01.52.126.617.90.22.8
20EntryStockNamePedigreeAnthDays toASIPlantEarEarLodgingEars/HuskEarGLSE.turcGrainNumMSVEar
21IDFWRankDateSilkHeightHeightPositionRootStemPlantCoverRotMoistPlantsAspect
22
23t/haRankdddcmcm0-1%%#%%1-51-5%#1-51-5
24
251D1731-1CKH212481CML566/DL171945//DL1769726.746769711266151115361.11-31.52.325.116.20.02.9
262D1731-2CKH212482CML566/DL171945//CML3125.3288707012401321-121.1-9-101.72.131.011.30.03.5
273D1731-3CKH212483CML566/DL171945//DL1717067.95366766(1)261143111431.1001.72.328.318.10.02.2
284D1731-4CKH212484CML566/DL171945//DL124165.92826869122112714490.9421.72.527.918.00.02.9
295D1731-5CKH212485CML566/DL171945//DL1727238.26286767(0)2261281151.2-5-41.72.333.517.80.02.7
306D1731-6CKH212486CML566/DL171945//DL143879.9246767024114319250.9-8-52.22.121.119.40.02.7
317D1731-7CKH212487CML566/DL171945//DL1726906.9662707222481471271.118-71.42.127.917.50.52.9
328D1731-8CKH212488CML566/DL171945//CML5368.37267171(0)2521461331.0-541.21.528.019.40.02.5
339D1731-9CKH212489CML566/DL171945//CZL11356.05816665(0)230128113250.9871.02.322.118.00.03.5
3410D1731-10CKH212490CML566/DL171945//CZL1503710.9126767(0)25612618131.1-5-31.72.025.920.11.52.3
3511D1731-11CKH212491CML566/DL171945//CL1471657.7642696902321181271.0-3-41.51.831.318.70.02.6
3612D1731-12CKH212492CML566/DL171945//DL1770199.2310696902411331101.1-4-41.22.529.719.20.02.9
3713D1731-13CKH212493CML444/CKL14549//DL1769727.943769712260159114251.0-4-51.72.326.318.00.02.3
3814D1731-14CKH212494CML444/CKL14549//CML3128.59196969124014413371.1-801.52.128.811.20.03.5
3915D1731-15CKH212495CML444/CKL14549//DL1717066.89656970122712912170.92041.52.125.616.70.53.0
4016D1731-16CKH212496CML444/CKL14549//DL124167.2057686912141231-1271.0-3-61.72.328.519.22.02.8
4117D1731-17CKH212497CML444/CKL14549//DL1727237.92396868(0)22912517151.0-4101.52.326.820.00.02.5
4218D1731-18CKH212498CML444/CKL14549//DL143879.11146970223213615161.1-6-72.02.525.119.70.52.5
4319D1731-19CKH212499CML444/CKL14549//DL1726906.13797071124716112141.05101.52.028.419.70.02.7
4420D1731-20CKH212500CML444/CKL14549//CML5369.5486968(0)2621451541.0-6-61.21.831.520.00.52.3
Results
Cell Formulas
RangeFormula
AC4:AP4,AR4,AV4:AY4AC4=COUNT(AC25:AC114)
AC5:AP5,AR5,AV5:AY5AC5=AVERAGE(AC25:AC114)
Cells with Data Validation
CellAllowCriteria
AA1:AY1List=rTrial
 
Upvote 0
David, please let me know if it is now clear about the headers.
The data range to search for the string is everything from row 25 and it may also be sitting in hidden columns D and E.
Thanks a lot.
 
Upvote 0
???? I don't see the headers corresponding to anything? Dave
The headers are column labels for the data that we are searching from row25 down. When we get a hit copy the entire row to the destination WB, the information will be under those labels. As the stack grows, the a hit may contain a piece of data that has a label that has never been used, therefore we would need this new label to be introduced at row1 far right.

Or simply put, let’s get all hits from row25 in all worksheets named “Results” placed in a new WB using entire row copy paste to the output.
 
Last edited:
Upvote 0
Headers like "entry", "stock ID", "Name", etc? Those terms don't show up anywhere in the corresponding column rows 25 down? Dave
 
Upvote 0
Headers like "entry", "stock ID", "Name", etc? Those terms don't show up anywhere in the corresponding column rows 25 down? Dave
Dave- Now I get you! Ignore everything from row2 to row 24. Those rows are used for other purposes. My interest is row1 then every data from row 25 downwards.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,854
Members
449,051
Latest member
excelquestion515

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
Back
Top