Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Aquiring Directory names


Good afternoon all,

Would like to know how to...

1. Aquire a list of folder names
2. Add the list to worksheets("").range("")
3. Add the list from the range in the worksheet to a combobox

EG:

Press a button it looks in EXAMPLE location: "X:/EXAMPLE/EXAMPLE/"
Then returns the list of directories within this location. The list i
then added to a worksheet, and then to a combobox.

Thank you in advance

--
aking198
-----------------------------------------------------------------------
aking1987's Profile: http://www.excelforum.com/member.php...fo&userid=1539
View this thread: http://www.excelforum.com/showthread.php?threadid=31375

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Aquiring Directory names

Here is some code to get a list of all folders into a range. To add it to a
combobox, link the cb to the range.

Dim FSO As Object
Dim cnt As Long
Dim arfiles

Sub Folders()
Dim i As Long
Dim sFolder As String

Set FSO = CreateObject("Scripting.FileSystemObject")

arfiles = Array()
cnt = 0

sFolder = "C:\myTest"
ReDim arfiles(1)
If sFolder < "" Then
SelectFiles sFolder
Worksheets.Add.Name = "Folders"
With ActiveSheet
For i = LBound(arfiles) To UBound(arfiles)
.Cells(i + 1, 1) = arfiles(i)
Next
.Columns("A:Z").EntireColumn.AutoFit
End With
End If

End Sub

'-----------------------------------------------------------------------
Sub SelectFiles(Optional sPath As String)
'-----------------------------------------------------------------------
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object

ReDim Preserve arfiles(cnt)
arfiles(cnt) = sPath
cnt = cnt + 1

Set Folder = FSO.GetFolder(sPath)

For Each fldr In Folder.Subfolders
SelectFiles fldr.Path
Next

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"aking1987" wrote in message
...

Good afternoon all,

Would like to know how to...

1. Aquire a list of folder names
2. Add the list to worksheets("").range("")
3. Add the list from the range in the worksheet to a combobox

EG:

Press a button it looks in EXAMPLE location: "X:/EXAMPLE/EXAMPLE/"
Then returns the list of directories within this location. The list is
then added to a worksheet, and then to a combobox.

Thank you in advance.


--
aking1987
------------------------------------------------------------------------
aking1987's Profile:

http://www.excelforum.com/member.php...o&userid=15393
View this thread: http://www.excelforum.com/showthread...hreadid=313753



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting email address names in a range of cells to real names John Excel Worksheet Functions 1 May 19th 10 03:44 PM
Aquiring data from one sheet to another sheet in the same workbook No News Excel Worksheet Functions 10 August 1st 06 08:01 AM
to convert all the file names in one directory to .xls? S.G.Pillai Excel Discussion (Misc queries) 2 September 27th 05 05:13 PM
Change names of files in a folder to match names in Excel Column saybut Excel Programming 4 February 9th 04 06:26 PM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM


All times are GMT +1. The time now is 07:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"