insert all excel files name into excel from folder

Rahulwork

Active Member
Joined
Jun 9, 2013
Messages
284
hello everyone

i want to insert all excel file into exceel from specific path metioned in A1

target or destination cell would be B1
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
This will list all Excel files in the folder whose path is specified in A1 of the active sheet. List will begin in B1.
VBA Code:
Sub ListExcelFiles()
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set F = fs.GetFolder(Range("A1").Value)
    iRow = 1
    On Error Resume Next
    For Each myfile In F.Files
        If myfile.Name Like "*.xls?" Then
            Cells(iRow, 2).Value = myfile.Name
            iRow = iRow + 1
            N = N + 1
        End If
    Next myfile
    Columns("B").AutoFit
    MsgBox N & " files listed"
End Sub
 
Upvote 0
 
Upvote 0
 
Upvote 0
Your "questions" in Posts #7 & #8 are two separate threads, not part of this thread, as they should be.
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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