Need expertise help...

kilosub

Board Regular
Joined
Jan 7, 2009
Messages
116
Hi All,

How do I extract data from multiple files with a standard structure into a single sheet.

Raw input
C3 - text
C4 - text
C5 - text
C6 - text
C7 - text
C8 - numeric
C9 - numeric ( formatted as "000-000-0000")

Desire Output
B2 - extraction from file
B3 - extraction from file
and so on.

I have close to 300 files.

I hope I didn't confuse you all...

Thanks in advance.

Cheers,

Kilosub
 
Oops, reverse thing:
Code:
Sub ExtractData()
    
    Dim j As Long
    Dim fso As New FileSystemObject, aFile As File
    Dim this As Worksheet, wkb As Workbook, sh As Worksheet
    
    j = 2
    
    Set this = ActiveSheet
    
    For Each aFile In fso.GetFolder(ThisWorkbook.Path).Files
        
        If fso.GetExtensionName(aFile.Name) Like "xls*" Then
        
            Set wkb = Workbooks.Open(aFile.Path)
            Set sh = wkb.Sheets(1)
            
            sh.Range("C3:C9").Copy
            this.Cells([B][COLOR="Red"]j, "B"[/COLOR][/B]).PasteSpecial xlPasteValues
            j = j + 1
           
            wkb.Close SaveChanges:=False
            
        End If
        
    Next

End Sub
 
Upvote 0

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
It must work 'cause every time code finds Excel file, it advances row (variable j)...
 
Upvote 0
Confirm, its overlapping like the earlier result, after the modification. Not sure about "B" thing to me. We're close to the desire output. Below is the current and desire output.


Current Output
Name_1 | Name_2 | Name_3
Dept_1 | Dept_2 | Dept_3
Add_1a | Add_2a | Add_3a
Add_1b | Add_2b | Add_3b
Add_1c | Add_2c | Add_3c
12345 | 67890 | 20987
234567890 |435753267 |986246427


Desire Output
Name_1 | Dept_1 | Add_1a | Add_1b | Add_1c | 12345 | 234567890

Name_2 | Dept_2 | Add_2a | Add_2b | Add_2c | 67890 | 435753267

Name_3 | Dept_3 | Add_3a | Add_3b | Add_3c | 20987 | 986246427


Thanks.
 
Last edited:
Upvote 0
Hi,

Can anyone assist me to refine the coding? It is completed. The only thing the output require is by rows and not by column.

Thanks to sektor who provide the coding but with respect to sektor, I need to get these done by today.


Thanks in advance.
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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