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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,575
Messages
6,125,613
Members
449,238
Latest member
wcbyers

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