+ Reply to Thread
Results 1 to 22 of 22

Creating Folders based on cell values

  1. #1
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Question Creating Folders based on cell values

    Hi All,

    Wondered if some bright spark can assist with an issue im having?

    I have a spreadsheet which has product column on the left and to the right are various document names as column headers.

    I have colour codes: Green = Received, Orange = Requested, Red = attention. Users enter short text in the cells to describe the present position of the document, and colour code accordingly.

    Scenario
    (assume directory is already created as : "Product Name/Document header/<date & cell value here>) - bolded is already created in the directory.

    User clicks on a cell, and clicks on "create folder" button. The button should pull the Product Name from the spreadsheet, pull the relevant document column header from where the user has selected the cell and create a new folder as above based on the date and active cell text: "<date & cell value/text here>". The date should be in this format yyyy/mm/dd so that the folders flow down the directory in date order, so that the folders are not in random order.

    I want the "create folder" button to also check if the folder already exists as to not overwrite any previously created folder with the same date and cell value/text.


    The aim is that the spreadsheet will be used as the hub.

    Look forward to any replies and suggestions,

    Best wishes.
    Last edited by vbwanab; 06-19-2011 at 05:13 AM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Creating Folders based on cell values

    is it possible to attach a sample file so we have something to work on? It is always easier with examples.

  3. #3
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Smile Re: Creating Folders based on cell values

    Hi there, thank you for the quick response.

    Please see attached. I have added some requirements if that is ok, most of which seem straight forward (to a pro). Thought id add them to save asking again.

    If you look at the black bordered items and probably will make more sense to start with "create folders" example.

    Again, thank you and i appreciate your help.

    Example created in Excel 07

    Best wishes!
    Attached Files Attached Files

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Creating Folders based on cell values

    you're asking to create folders but what documents are going to be in those folders. I have but no clue.

  5. #5
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Creating Folders based on cell values

    I didnt think it mattered what docs are going to be in the folders as the users will just be dragging and dropping the docs into the folders that are created by the Spreadsheet.. The main issue is what is outlined in the spreadsheet, would appreciate your help if you have an idea as to how to go about it.

    The spreadsheet outlined a couple of the docs but there are many more, i just need an example (hence the spreadsheet) and i can do the rest..THe docs will be pdf's word docs etc, but i didnt think this mattered as mentioned. Thanks for your help,

    THanks for your help,
    Last edited by vbwanab; 06-07-2011 at 04:15 PM.

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Creating Folders based on cell values

    here is a start for you to work on.
    I created the "Create folder", "Open activecell folder" and "Open top folder" macros and they are assigned to your buttons.
    I had to replace the "/" in the folder name with "-" because it was giving an error.
    Hope this help
    Pierre
    Attached Files Attached Files

  7. #7
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Creating Folders based on cell values

    in the attached file, you'll be able to open PDF and DOC file. In the previous reply, the file was just showing you the folder but there was no program to open the file. You'll need some more programming if you want to open other file type.
    Attached Files Attached Files

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Creating Folders based on cell values

    'MAKE FOLDERS AND SUBFOLDERS
    Here's a macro for creating all the folders and subfolders in path. There's a macro and a UDF version that other macros can use.
    Make Folders and Subfolders



    Based on that, I edited it down to your scenario. This will create the folders desired based on the ACTIVECELL, so after someone enters text anywhere in your key section, the cell highlighted is the one used when the macro is activated. Here is the result:

    Please Login or Register  to view this content.


    This code actually does a little more than you asked. It creates all the folders and subfolders from the top level down to the bottom. Of course, if your upper folders already exist it just moves on. This macro assumes C:\ drive is root.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  9. #9
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Creating Folders based on cell values

    bleeding heck, thanks a lot guys you are a helpful bunch!

    I will try some out on the weekend and provide an update of course!

    With regards to the file types, excuse my ignorance but i still dont get why this matters? The users create and open the folders from the spreadsheet and they drop relevant files in the folders. Maybe i left out that the users will have adobe/word etc but i thought that was presumed since they are the ones that are dropping the files in the created folders. Does this make sense or am i missing something? A side note is that the folders are created and opened within windows explorer, but again i presume that was realised from the example?

    Hope this doesnt come across ungrateful, because i am very grateful for the help, thank you all for your help, i will come back shortly on this,,in the meantime, a pointer regarding my above ignorance would be welcome.
    Last edited by vbwanab; 06-08-2011 at 02:39 PM.

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Creating Folders based on cell values

    I don't understand the question posed earlier about what files you're going to put into these created folders, either. But the macro I provided will create folders based on the selected cell when you run it.

  11. #11
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Creating Folders based on cell values

    Hi Jerry, Thank you very much for the example, i have adapted it for my spreadhsheet as i realised i may need more dir levels and it works perfectly. Thanks very much for your kind help. Thank you also pierre for your help.

    Was curious though, you know the code

    Please Login or Register  to view this content.
    Why does it say "row, 1" when in actual fact it is column 1 it pulls the product name from? It works fine was just curious? Similarly, column 3 when it is row 3 it pulls the sub dir from? Maybe i am reading it in the wrong context?

    Do you think you could help with the remainder on my spreadsheet example? I will figure out the "open folder" bit, that cant be hard. It was the "Add note example" i was looking for next.

    I would like it to basically pop up entry boxes for the user to input the data as shown on the spreadsheet (pop up entry boxes will be good to restrict their input in the comment), then to insert as comment on the active cell. If there is already a comment in a cell and the user hits add note button, it should start the process again but simply append to the existing one.



    BW
    Last edited by vbwanab; 06-12-2011 at 11:20 AM.

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Creating Folders based on cell values

    Wouldn't this suffice ?

    Please Login or Register  to view this content.



  13. #13
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Creating Folders based on cell values

    The code jerry posted was fine, it works fine as mentioned.

    The second part of my query is as outlined in bold on my previous post.

    Thanks for your help,

  14. #14
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Creating Folders based on cell values

    Quote Originally Posted by vbwanab View Post
    Was curious though, you know the code

    Please Login or Register  to view this content.
    Why does it say "row, 1" when in actual fact it is column 1 it pulls the product name from? It works fine was just curious? Similarly, column 3 when it is row 3 it pulls the sub dir from? Maybe i am reading it in the wrong context?
    The Cells() syntax is as follows:

    Cell(RowReference, ColumnReference)

    So there are two parameters being given values each time it is used. In the first example, Cells(.Row, 1)
    ...you see the ROW is taken from the row of the Activecell (notice the "with" reference above it?) and we've hardcoded the column to column 1.

    The second Cells() formula for the end next part of the path is coming from row 3, the code is Cells(3, .Column)(
    ...so the row is hardcoded as 3, but the column is taken from the Activecell.

    Is that clear how the CELLS() function works? Each parameter is a numeric value.

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Creating Folders based on cell values

    You don't need two separate buttons for the notes, you could build the capability in like so:
    Please Login or Register  to view this content.

    This will add the boilerplate text into a new comment box if none exists, or it will add a new "instance" of the boilerplate into an existing comment, incrementing the receipt #.

    Of course, the answers still need to be added by the user, EDIT > COMMENT.

  16. #16
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Creating Folders based on cell values

    I just reread it and noticed the "popup and ask questions" idea. This will do that...much longer code, of course...
    Please Login or Register  to view this content.


    To edit an existing comment, just right-click the target cell end choose Edit Comment.

  17. #17
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Creating Folders based on cell values

    The two buttons for opening the activecell folder/top folder:
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Creating Folders based on cell values

    Hi Jerry,

    Thanks very much for the response. I understand with your very well explained post re the row/column syntax now.I ignorantly presumed if row and 1 were in the same bracket, this equaled row 1, which it doesn't.


    Thanks for the code re the notes button, i will give this a go and post feedback.

  19. #19
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Creating Folders based on cell values

    Wow, i just noticed you posted again after the iniital "notes code" you mentioned.

    Thanks for the code for practically all of my requirements Amazing how much this forum gives. I'm a bit gutted all i can "give" at this present time is a click on your scales ...

    Will post back with comments shortly.

  20. #20
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Creating Folders based on cell values

    Hi Jerry, Any ideas on how to capture the batch number as alpha numeric type? I looked it up but there doesnt seem to be a type to cover this?


    EDIT
    Never mind i just copied the Further comment code
    Last edited by vbwanab; 06-13-2011 at 09:09 AM.

  21. #21
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Creating Folders based on cell values

    My apologies, you just needed to edit the Type:=1 to Type:=2. 1 is numeric, 2 is text.

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  22. #22
    Registered User
    Join Date
    03-27-2009
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Creating Folders based on cell values

    Thank you for the assistance. Thread marked as solved.

+ 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