Open several excel files and extract data for specific text

fgcmx

New Member
Joined
Jun 26, 2008
Messages
1
Hello,
would you please help me, i'm stuck with this problem

i have several files that have information in two columns: A the name and B the data, i need to collect the data (in column B) of all the files and subfiles of the folder where the name is (the name i'm looking for could be on different rows) Part #: and part Name:

<table style="width: 197pt; border-collapse: collapse;" x:str="" border="0" cellpadding="0" cellspacing="0" width="262"><colgroup><col style="width: 139pt;" width="185"><col style="width: 58pt;" width="77"></colgroup><tbody><tr style="height: 12.75pt;" height="17"><td class="xl22" style="border: medium none rgb(236, 233, 216); width: 139pt; height: 12.75pt; background-color: transparent;" height="17" width="185">Part #:</td><td class="xl23" style="border: medium none rgb(236, 233, 216); width: 58pt; background-color: transparent;" x:num="1234567890" width="77">1234567890</td></tr><tr style="height: 12.75pt;" height="17"><td class="xl22" style="border: medium none rgb(236, 233, 216); height: 12.75pt; background-color: transparent;" height="17">Revision:</td><td class="xl23" style="border: medium none rgb(236, 233, 216); background-color: transparent;">
</td></tr><tr style="height: 12.75pt;" height="17"><td class="xl22" style="border: medium none rgb(236, 233, 216); height: 12.75pt; background-color: transparent;" height="17">Part Name:</td><td class="xl23" style="border: medium none rgb(236, 233, 216); background-color: transparent;">new cover black ink</td></tr><tr style="height: 12.75pt;" height="17"><td class="xl22" style="border: medium none rgb(236, 233, 216); height: 12.75pt; background-color: transparent;" height="17">Manufacturing Location:</td><td class="xl23" style="border: medium none rgb(236, 233, 216); background-color: transparent;">Queretaro</td></tr><tr style="height: 12.75pt;" height="17"><td class="xl22" style="border: medium none rgb(236, 233, 216); height: 12.75pt; background-color: transparent;" height="17">Date:</td><td class="xl24" style="border: medium none rgb(236, 233, 216); background-color: transparent;">17-04-07</td></tr><tr style="height: 12.75pt;" height="17"><td class="xl22" style="border: medium none rgb(236, 233, 216); height: 12.75pt; background-color: transparent;" height="17">Quote prepared by:</td><td class="xl25" style="border: medium none rgb(236, 233, 216); background-color: transparent;">PGC</td></tr></tbody></table>

I'm using this code, but it only gave me the value on the cell A5, and only for the files that are on Q:\Estimating\customer\ and not in the subfolders.

Code:
Sub ListFilesInFolder()
    Application.ScreenUpdating = False
     
    Dim FN As String ' For File  Name
    Dim ThisRow As Long
    Dim FileLocation As String
    Dim xlMaster As Worksheet, xlData As Worksheet
     
    Set xlMaster = ActiveWorkbook.ActiveSheet
    ThisRow = 2
    FileLocation = "Q:\Estimating\customer\"
    FN = Dir(FileLocation)
     
    With xlMaster
        Do Until FN = ""
            ThisRow = ThisRow + 1
            .Cells(ThisRow, 1) = FN ' Puts filename in first column
            .Cells(ThisRow, 2) = FileDateTime(FileLocation & FN) ' puts  date last modified in second column
            FN = Dir
             
            If open_file(FileLocation, .Cells(ThisRow, 1)) Then
                Set xlData = ActiveWorkbook.ActiveSheet
                .Cells(ThisRow, 3) = xlData.Range("a5")
                xlData.Parent.Close False
                 'uncomment the else and exit to stop processing if unable to open a file.
                 'or put in your own  error handling
                 'Else
                 'Exit Sub
            End If
         Loop
    End With
    Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,191,047
Messages
5,984,350
Members
439,882
Latest member
gerdc

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
Top