Get PDF file names and fill column with it

MartinVW

New Member
Joined
Aug 9, 2013
Messages
31
I have a list of PDF files in a folder. I wanted to know how exactly would I write a vbscript to go into the folder, take the file path and put it in an excel worksheet in column A and offset it until all the files have been caught. Also I know this is probably an easy question and an easy macro to write, and to prevent asking questions like this again in the future can someone also (if you don't mind) lead me to a great place to learn vba? I'm more of a visual person so book's don't really help me. Thank you so much
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hello MartinVW,

Here is amacro to list the PDF files in a folder. The folder name is in "A1" of the active sheet. The file names will be listed starting in "A2".

Code:
Sub ListPDFs()

    Dim Filename As String
    Dim Filepath As String
    Dim r As Long
    
        Filepath = Range("A1")
        If Right(Filepath, 1) <> "\" Then Filepath = Filepath & "\"
        
            Filename = Dir(Filepath & "*.pdf")
            
            Do While Filename <> ""
                r = r + 1
                Range("A1").Offset(r, 1) = Filename
                Filename = Dir()
            Loop
            
End Sub
 
Upvote 0
Thank you this is exactly what I need. Question would you have to know an excellent site that helps you learn vba but like with videos? Because I really need to learn VBA but I'm not good with reading to learn.
 
Upvote 0
Hello MartinVW,

I have seen a lot of videos about Excel on YouTube, mostly on formulas. I really don't know of any sites that are heavy with video teaching for VBA. Sorry, it is not an area that I have investigated because I don't have a need for it.
 
Upvote 0

Forum statistics

Threads
1,215,831
Messages
6,127,137
Members
449,361
Latest member
VBquery757

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