+ Reply to Thread
Results 1 to 11 of 11

Probems putting folders into other folders based on user input.

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Probems putting folders into other folders based on user input.

    Hello everyone. I recently developed some script which will produce a series of folders based on a user inputing a date that it is enetered in a message box using the dd-mmm-yyyy format. The date that is entered is always the last day of a quarter. So for example it will be one of the following:

    i. March 31
    ii. June 30
    iii. September 30
    iv. December 31

    Now what I have are four folders labeled

    1. 1 Quarter
    2. 2 Quarter
    3. 3 Quarter
    4. 4 Quarter

    And here is where I am stuck If the user enters a date of say 30-Jun-2010 as you can see form the code below it will produce the following:

    A. a folder labeled 30-Jun-2010...and some subfolders
    B. a folder labeled 31-May-2010...and some subfolders
    C. a folder labeled 30-Apr-2010...and some subfolders

    Now what I cannot fogure out is how to take A,B and C and place them into the 2 Quarter folder. Similairyl if a user enters the date of 31-Mar-2010 then the folders that are created by the script need to be put into the 1 Quarter folder...and so on. Any help is appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Probems putting folders into other folders based on user input.

    Do these Quarter folders already exists, or are you trying to create them first to put your other folders inside of?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Probems putting folders into other folders based on user input.

    The folders already exist.

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Probems putting folders into other folders based on user input.

    Ok, assuming the Quarter folders are at L:\Quarter1 etc. the following code will add the quarter name to the path:

    Please Login or Register  to view this content.
    I'd put it right after where you define fpath as L:\

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Probems putting folders into other folders based on user input.

    i did that and it tells me I have a "type mismatch. see the code below

    Please Login or Register  to view this content.

  6. #6
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Probems putting folders into other folders based on user input.

    I'm sorry, I can't believe I copied that wrong. It should be

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Probems putting folders into other folders based on user input.

    We are close, now it tells me that "those folder already existed"

  8. #8
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Probems putting folders into other folders based on user input.

    According to the intermediate window there is an error here:

    Case Month(fDate)

    with an "expected expression"

  9. #9
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Probems putting folders into other folders based on user input.

    What line does the code stop on when it crashes?

  10. #10
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2007
    Posts
    458

    Re: Probems putting folders into other folders based on user input.

    It does not crash. It simply tells me the folders already exist when in fact they do not. Any other suggestions?

  11. #11
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Probems putting folders into other folders based on user input.

    Run the code to the first MkDir Fldr. (You can put in bookmarks to stop the code in a certain spot by clicking the margin to the left of the code.)
    Type the following into the immediate window, and hit enter:

    Please Login or Register  to view this content.
    This will show you that path of the folder you are attempting to create. Check and make sure it does not exist.

+ 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