ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Populating ComboBox with Folder Names (https://www.excelbanter.com/excel-programming/355444-populating-combobox-folder-names.html)

Tyrell

Populating ComboBox with Folder Names
 
How do I fill a combo box with a list of folders in order to enter the folder
that is selected from that list?
Ex.: Folders - Customer 1
Customer 2
Customer 3
Select - Customer 1 and enter into that folder upon selection to
view and select a folder within Cutomer 1.

Then, how do I fill a combo box with a list of names of Excel workbooks that
are in a selected folder in the same manner as above?
--
Tyrell Fickenscher
Plant Manager / Agronomist

Bob Phillips[_6_]

Populating ComboBox with Folder Names
 
With Combobox1
.Additem "Customer 1"
.Additem "Customer 2"
'etc.
End With

and

Dim FSO As Object
Dim sFolder As String
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object

Set FSO = CreateObject("Scripting.FileSystemObject")

Set this = ActiveWorkbook
sFolder = Combobox1.Value
If sFolder < "" Then
Set Folder = FSO.GetFolder(sFolder)

Set Files = Folder.Files
For Each file In Files
If file.Type = "Microsoft Excel Worksheet" Then
Combobox2.Additem file.Name
End If
Next file

End If ' sFolder < ""

Set FSO = Nothing



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Tyrell" wrote in message
...
How do I fill a combo box with a list of folders in order to enter the

folder
that is selected from that list?
Ex.: Folders - Customer 1
Customer 2
Customer 3
Select - Customer 1 and enter into that folder upon selection

to
view and select a folder within Cutomer 1.

Then, how do I fill a combo box with a list of names of Excel workbooks

that
are in a selected folder in the same manner as above?
--
Tyrell Fickenscher
Plant Manager / Agronomist





All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com