Avatar of Billa7
Billa7
 asked on

Copy Title

Hi Experts,

I need Experts help. I have 1000 over files in the External Drive (G:\) and I need to extract those files' name and copied into excel sheet (Column A). Hope Experts could help me create a macro which is able to do this.
Title.xlsx
Microsoft Excel

Avatar of undefined
Last Comment
Billa7

8/22/2022 - Mon
SOLUTION
Marc Z

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jornak

Sub ListDirectory() 
     
    Dim oFSO As Object 
    Dim oFolder As Object 
    Dim oFile As Object 
    Dim ws As Worksheet 
     
    Set oFSO = CreateObject("Scripting.FileSystemObject") 
    Set ws = Worksheets.Add 
    Set oFolder = oFSO.GetFolder("G:\") 
        
    For Each oFile In oFolder.Files 
        ws.Cells(ws.UsedRange.Rows.Count + 1, 1).Value = oFile.Name 
    Next 

    Set oFolder = Nothing 
    Set oFile = Nothing 
    Set oFSO = Nothing 
     
End Sub 

Open in new window

Kyle Abrahams

Billa7

ASKER
Hi Jornak,

I have tested your code, it's not populating the file titles at column A. It's just copied a single file name only.
Your help has saved me hundreds of hours of internet surfing.
fblack61
SOLUTION
Jornak

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Billa7

ASKER
Hi,

Thanks for the help.