Prev: Better protection for VBA project?
Next: Change Number to Text , Case error when cell is String and format is General
From: damorrison on 18 Feb 2010 18:53 I had found this code to show folder names that displays in a msgbox, is it possible to get the list of folder names into a combobox? --------------------------------------- Sub ListFolders() Dim fs, f, f1, fc, s Dim folderspec folderspec = "C:\Excel\" Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set fc = f.SubFolders For Each f1 In fc s = s & f1.Name s = s & vbCrLf Next MsgBox s End Sub ---------------------------------------- This is for excel 2000 Thanks
From: dan dungan on 18 Feb 2010 19:05 is the combobox on a worksheet or a userform?
From: damorrison on 18 Feb 2010 19:12 On Feb 18, 5:05 pm, dan dungan <stagerob...(a)yahoo.com> wrote: > is the combobox on a worksheet or a userform? Thanks for the reply, it will be from the controlls toolbar that will be on the worksheet.
From: Dave Peterson on 18 Feb 2010 20:06 Option Explicit Sub ListFolders() Dim fs, f, f1, fc, s Dim folderspec folderspec = "C:\Excel\" Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFolder(folderspec) Set fc = f.SubFolders For Each f1 In fc Worksheets("Sheet1").ComboBox1.AddItem f1.Name Next f1 End Sub Change the name of the worksheet and the name of the combobox if you have to. damorrison wrote: > > On Feb 18, 5:05 pm, dan dungan <stagerob...(a)yahoo.com> wrote: > > is the combobox on a worksheet or a userform? > > Thanks for the reply, it will be from the controlls toolbar that will > be on the worksheet. -- Dave Peterson
From: damorrison on 18 Feb 2010 22:08
Thank you, that works great |