Download Folder Names into an Excel sheet

Nick70

Active Member
Joined
Aug 20, 2013
Messages
299
Office Version
  1. 365
Platform
  1. Windows
Hi,

What I need to do is quite simple.

I need to check that all clients have a specific sub-folder created for them in a specific folder (called Client Names) found in a directory.

I therefore need to download all the client sub-folders found in that folder (i.e. Client Names) to see if they match with my client list.
Every client sub-folder contains some excel files but I am NOT interested in these I only want the full list of client sub-folder names (each of which corresponds to a client name).

Folder 'Client Names' which contains client sub-folders is found in directory below:

C:\Users\user\OneDrive\Desktop\Client Names

Can you please let me know if there is an excel formula or a macro which can go into the directory look into 'Client Names' folder and return a list in an excel sheet of all sub-folders contained in it (i.e. the client names)?

Thanks,
Nic
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Upvote 0
Hi,

The original question from the thread you sent says:

'I need a macro to brings all files from folder and subfolders to multiple columns..."

What I need and I mentioned this in my email is not file names but folder names.

Is there a macro to extract folder names as opposed to file names?

Thanks,
Nic
 
Upvote 0
Yes like in the link where in posts #2 & 8 each code extracts first only the directories name, so just read & see …​
A must see in VBA help : Dir function …​
 
Upvote 0
Run this macro, the folder names will stay on the active sheet in cell A2 and down.

VBA Code:
Sub subfolders()
  Dim sPath As String, DirFile As String
  Dim i As Long
  
  sPath = "C:\Users\user\OneDrive\Desktop\Client Names\"
  DirFile = Dir(sPath, vbDirectory)
  i = 2
  Do While DirFile <> ""
    If DirFile <> "." And DirFile <> ".." And _
      ((GetAttr(sPath & DirFile) And vbDirectory) = 16) Then
      Range("A" & i).Value = DirFile
      i = i + 1
    End If
    DirFile = Dir
  Loop
End Sub
 
Upvote 0
Solution
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,225
Members
448,951
Latest member
jennlynn

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