+ Reply to Thread
Results 1 to 7 of 7

Creating folders from Excel Spreadsheet?

  1. #1
    Registered User
    Join Date
    01-03-2009
    Location
    Phoenix AZ
    MS-Off Ver
    Excel 2003
    Posts
    10

    Creating folders from Excel Spreadsheet?

    I need some help, I know very little about macros but is it possible to create folders/directories to a certain path using the text in an excel spreadsheet cell? For example, if cell a2 has a street address and cell b2 has a city, can it automatically create a directory in the path of my choice using that data? If yes, can it go down the the rows and create directories until it is done?

    Please help as I have hundreds of directories to create.

    Thank you in advance for your help.

    ps, I did do a search and found some info but I can not change the info to fit my situation.
    Last edited by azshaw; 01-03-2009 at 06:02 PM. Reason: Update subject

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello azshaw,

    Welcome to the Forum!

    This macro concatenates the cells in columns "A" and "B" to create a new folder name. This folder is then added to the default folder Excels stores your workbooks in. The macro reads down "Sheet1" until there is no more data in column "A". I have marked key variables in red so you can easily find and change them if needed.
    Please Login or Register  to view this content.
    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time.
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    To Run the Macro...
    To run the macro from Excel, open the workbook, and press ALT+F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    01-03-2009
    Location
    Phoenix AZ
    MS-Off Ver
    Excel 2003
    Posts
    10
    This is so helpful!!!! One more question, how do I specify a certain path?

    Thank you again, you have saved me a lot of time!!!

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    You mean the MainPath? Here are 3 examples.
    Please Login or Register  to view this content.
    If you mean the path for the Subfolders, they are in rows 2 and down.
    e.g. A2="298 Rainbow Lane", B2="Oz", MainPath="c:\stories\"
    the path would then be set to "c:\stories\298 Rainbow LaneOz"

    You might want to add a space or other character in your concatenation line such as:
    Please Login or Register  to view this content.
    I would recommend that you consider setting the City first and then the address so that you can sort in a view.
    e.g.
    Please Login or Register  to view this content.
    In this example, I used "_" to separate address from city.

  5. #5
    Registered User
    Join Date
    01-03-2009
    Location
    Phoenix AZ
    MS-Off Ver
    Excel 2003
    Posts
    10
    I think I missing something, here is my code

    Please Login or Register  to view this content.
    when I run it, I get an error message "Compile error: Invalid Next control variable reference" and ir highlights the word "cell" in blue.

    Thanks again for all your help!!!

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello azshaw,

    Oops! I changed the loop control from Cell to R, but didn't change the Next variable to R. Here is the corrected code...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    01-03-2009
    Location
    Phoenix AZ
    MS-Off Ver
    Excel 2003
    Posts
    10
    That did it!!!!

    Thank you so much!!!!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1