Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default displaying contents of a user defined directory

Hello,

How should a macro that read a user defined directory which is entered in
excel.
What I mean is:

1. In the mainsheet (Excel), user will enter the directory for the
main_folder.

2.Then , once user click on the "Search" button, it will list all the
subfolder (from the main_folder directory) in the mainsheet at a specified
row and column.Let say row 4, column "C".

-help needed ;(

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default displaying contents of a user defined directory

Hi

Public Function GetSubfolder(MyFolder As String, FolderNum As Integer,
Optional MyTime As Date)
Dim fs, f, f1, s, sf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(MyFolder)
Set sf = f.SubFolders
i = 0
For Each f1 In sf
i = i + 1
If i = FolderNum Then GetSubfolder = f1.Name
Next
End Function

Copy this UDF into workbook module.

On sheet MainSheet, I assume you have the folder string in cell p.e. A1
(like C:\Documents and Settings\MyProfile\My Documents\)
Into A2, enter the formula
=IF(ISERROR(GetSubfolder($A$1,ROW()-1)),"",GetSubfolder($A$1,ROW()-1))
, and copy it down for some amount of rows.

(You can make the formula volatile, including TODAY() or NOW() as 3rd
parameter for 1st of GetSubFolder functions in formula)


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )


"cyzax7 via OfficeKB.com" <u22797@uwe wrote in message
news:618077d9b23a4@uwe...
Hello,

How should a macro that read a user defined directory which is entered in
excel.
What I mean is:

1. In the mainsheet (Excel), user will enter the directory for the
main_folder.

2.Then , once user click on the "Search" button, it will list all the
subfolder (from the main_folder directory) in the mainsheet at a specified
row and column.Let say row 4, column "C".

-help needed ;(

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200606/1



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
"User-defined type not defined" message in Excel RW1946 Excel Discussion (Misc queries) 0 August 31st 05 12:14 PM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
Workspace faux user-defined type not defined Chris S[_2_] Excel Programming 3 November 11th 04 05:51 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
Word.Document - user defined type not defined jowatkins[_7_] Excel Programming 0 January 20th 04 08:46 AM


All times are GMT +1. The time now is 01:50 PM.

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"