List of picture names in an excel column

maddengm33

Board Regular
Joined
Jan 25, 2005
Messages
62
I have 15 pictures in a folder named PIX located in my C drive (C:\PIX). All the pictures are .jpg images. I would like a list of all of the pictures in the folder PIX in the A column on an excel spreadsheet. What VBA code would I need to run to accomplish this?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Perhaps something like this:
Code:
Sub ListPIX()
Dim I As Integer
Dim PIXFile As String
    With Application.FileSearch
        .NewSearch
        .LookIn = "C:\Papers\"
        .Filename = "*.j*g"
        .Execute
        
        For I = 1 To .FoundFiles.Count
        
            PIXFile = Mid(.FoundFiles(I), InStrRev(.FoundFiles(I), "\") + 1)
            
            Range("A" & I) = PIXFile
            
        Next I
    End With
End Sub

Note this uses the function InStrRev to extract only the file name. This is available in later versions of Excel.
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

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