+ Reply to Thread
Results 1 to 6 of 6

Get filename by folders

  1. #1
    Registered User
    Join Date
    10-12-2014
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    54

    Get filename by folders

    Hi All,

    I had a post show below about file names on cells. This turned our great and is working like a beast for my application.

    https://www.excelforum.com/excel-pro...file-code.html

    So my question is if I have designated folders that have lower file count I would rather select the folder rather than going inside and select all.
    I would want it to write on cell B2 and onwards but if I decided to add more files (from another directory) I would want it to append the end of the list so it doesn't overwrite on Cell B2 and onwards.

    You guys are so helpful and I appreciate your feedback.
    Cheers

    atomichybrid

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Get filename by folders

    Try this. In the 1st window select the directory you wish to scan.

    If filecount < 40 then listing is automatic else filepicker opens.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    10-12-2014
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    54

    Re: Get filename by folders

    Hi bakerman2,

    Your code works for what you've mentioned. I like this creative approach if it has less than 40 files then it will add to the list otherwise it will go to file picker.
    Though playing around with the VBA, hitting the "Cancel' still continues to the code and hit around,

    Please Login or Register  to view this content.
    This is assuming if I have not selected anything in case I accidentally clicked the button or something. I think there is a work around to make it say something like you clicked cancel so it doesnt scare the user that an error code had happened, I remember seeing some kind of video for this but I'm not sure if its implementable.

    Also when the directory is less than 40 the files add but still opens a dialogue of the directory I chose. I assuming after the first 'with' code is complete the VBA continues to run the next 'with' code which is meant for folders exceeding the 40 file limit. Is this correct based on reading your code?

    This is pretty good for the early stages of your code.

    Please Login or Register  to view this content.
    I'm not sure if this part is necessary to scan directories, unless this is the only workaround for file limit scanning. I am quite happy to have the folder only option and create a separate button for the file picker version.

    Look forward to your feedback.

    atomichybrid

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Get filename by folders

    My bad, didn't test enough.

    Next code should do as expected.

    Please Login or Register  to view this content.
    PS: you can change 40 to another number more to your liking if you wish.

  5. #5
    Registered User
    Join Date
    10-12-2014
    Location
    Australia
    MS-Off Ver
    2019
    Posts
    54

    Re: Get filename by folders

    Hi bakerman2,

    Thanks for revising the code and it now works like a beast!
    Thanks heaps for your help, this will save me lots of time and processes with this.

    I would love to give you more reputation but I seem to get this notice perhaps I gave too much?

    "You must spread some Reputation around before giving it to bakerman2 again."

    atomichybrid

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Get filename by folders

    You're welcome and thanks for rep+.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Rename Files in sub-folders recursively using part of filename as a rule.
    By fokeiro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2017, 02:08 PM
  2. [SOLVED] Create folders and Sub folders and Sub-Sub folders from 5 columns with VBA
    By arleutwyler in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-11-2014, 04:16 PM
  3. Replies: 1
    Last Post: 09-12-2013, 09:23 PM
  4. Replies: 0
    Last Post: 12-04-2012, 01:01 PM
  5. Search all network folders for specific filename.
    By swoop99 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-29-2012, 06:05 AM
  6. Moving files with certain filename qualities to folders
    By svalentine in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-11-2011, 04:00 PM
  7. Changing filename colors in folders
    By Excel_Learner42 in forum Excel General
    Replies: 2
    Last Post: 01-06-2009, 06:30 PM

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