MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 13th, 2002, 10:22 AM   #1
neo
New Member
 
Join Date: Mar 2002
Location: Birmingham, Al
Posts: 19
Default

I'm just trying to get a simple directory listing of my hard drive into Excel 2000. I want to bring the list of folders, subfolders, and files into an Excel sheet. Simple enough, right?

I can get the files IN a particular folder to list themselves on the sheet using the Dir function and a loop, but I can't for the life of me figure out how to get the FOLDERS and SUBfolders to list. The closest thing I've found are the "folders" and "subfolders" properties, but I don't believe these apply...

I'm just trying to get this listing for my network so the backup operator can, at any time, run the macros in this workbook and get a directory listing of what's on a particular hard drive in an Excel format where it's easy to analyze (for choosing what to backup) and gives the admin a logfile to see what's being backed up.

Any help on this would be wonderful! I've been banging my head on a wall (or my screen, rather (c: ) for 2-1/2 days!!

Thanks,

neo

[ This Message was edited by: neo on 2002-03-13 09:23 ]

[ This Message was edited by: neo on 2002-03-13 09:25 ]
neo is offline   Reply With Quote
Old Mar 13th, 2002, 11:06 AM   #2
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

Slap your code up and let us see what you've got. (or pull out the pertinent bits of code)

It doesn't sound like it should be too dificult.
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old Mar 13th, 2002, 11:14 AM   #3
Joe Was
MrExcel MVP
 
Joe Was's Avatar
 
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
Default

Sub Look_In_x()
Dim lngCellCounter As Long
Dim Message, Title, Default, MyDir
'Search current directory for all files.

Application.ScreenUpdating = False
Message = "Enter the directory to search?" & Chr(13) & Chr(13) & "(Drive:DirectorySubDirectory)" ' Set prompt.
Title = "Enter: Drive and Path!" ' Set title.
Default = "H:Users" ' Set your default here first!.
' Display message, title, and default value.
On Error GoTo myErr

MyDir = InputBox(Message, Title, Default)

With Application.FileSearch
.NewSearch
.FileType = msoFileTypeExcelWorkbooks
.LookIn = MyDir
.SearchSubFolders = True
If .Execute() > 0 Then

MsgBox "There were " & .FoundFiles.Count & " file(s) found."

For lngCellCounter = 1 To .FoundFiles.Count
Cells(lngCellCounter, 1) = .FoundFiles(lngCellCounter)
Sheets("Sheet1").Select
Next lngCellCounter

Range("A1").Select
Selection.EntireRow.Insert
Range("AA2").Select
Selection.Copy
Range("A1").Select
ActiveSheet.Paste
Else

MsgBox "No Excel WorkBooks found!"
End If

End With
Application.ScreenUpdating = True
End
myErr:

MsgBox "No Excel WorkBooks found!"

End Sub

Note: This will list the found files on sheet1 cell A1 of the workbook using this code. Cell AA2 is a title for the displayed list, like: "These files found."
Sub Delete_Data()
'Delete the current screen print of file data.

Application.ScreenUpdating = False
Columns("A:A").Select
Selection.ClearContents
Range("A1").Select
Selection.EntireRow.Delete
Range("C1").Select
Application.ScreenUpdating = True
End Sub

This code will delete the list from Sheet1. JSW
Joe Was is offline   Reply With Quote
Old Mar 22nd, 2002, 01:28 PM   #4
neo
New Member
 
Join Date: Mar 2002
Location: Birmingham, Al
Posts: 19
Default

Joe!
I'm so sorry it took this long to respond, but Thank You dearly for your code! It worked perfectly! (of course, hehe)

Again, thank you (c:

neo

_________________
Check out Everquest. It's fun.

[ This Message was edited by: Juan Pablo G. on 2002-03-23 09:01 ]
neo is offline   Reply With Quote
Old Mar 22nd, 2002, 07:54 PM   #5
greg0226
New Member
 
Join Date: Feb 2002
Location: Benicia, CA
Posts: 31
Default

Hey Joe,

Just wanted to say that is some really nice code.

Greg
greg0226 is offline   Reply With Quote
Old Nov 21st, 2007, 12:04 PM   #6
casper_pkt
New Member
 
Join Date: Aug 2007
Location: Atlanta, GA.
Posts: 9
Default Code still in use

Another person using your code years after your post. good stuff - thanks for sharing.
casper_pkt is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 02:23 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes