• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Find & Add New Files To End of List

exc4libur

Member
Hello,

I am having a hard time trying to figure out how to do this, so any help is welcome!

I need a macro to add new files not listed in my table to the end of the list with the date that it was added and delete files listed in the table marked with an "x".

Thanks in advance!
:)
 
Can you upload an example showing what your table layout looks like currently? Are all files in the same folder? Does your table within XL have the folder address, or just file name?
 
Can you upload an example showing what your table layout looks like currently? Are all files in the same folder? Does your table within XL have the folder address, or just file name?

Hi Luke,

Thank you for answering. Sorry for the wait, I have uploaded the example you asked for.

- The files are in the same folder and there are no sub-folders.
- The macro should refresh my table adding the hyperlinks to old and new files.
- The table doesn't have the folder address, because the folder path is the same.

Rgds,
Exc4.
 

Attachments

Perfect, that should work nicely. Assumptions are that the folder path is listed in cell B2. To delete a file, put something in col E. Macro will look for any constant value (not a formula) and delete that file.
 
Perfect, that should work nicely. Assumptions are that the folder path is listed in cell B2. To delete a file, put something in col E. Macro will look for any constant value (not a formula) and delete that file.
Hi Luke,
Sorry, I'm confused. I've uploaded another file, that I believe is more comprehensive.

Thanks :)
 

Attachments

Bah, I see the problem. Check out line 40 in the code:
Code:
Set rngFound = .Range("A:A").Find(fileInFolder.Name)

If should be this:
Code:
Set rngFound = .Range("A:A").Find(what:=fileInFolder.Name, lookat:=xlWhole)

Previous line of code allowed a partial match to be found. So, when you already had found a file called
10ValidoValoresAtualizadosdoWACC120313.pdf

and then it looked for "13.pdf"

it found a partial match and was counting it. :( By changing the code to say look at whole cell, that issue should be resolved.
 
Bah, I see the problem. Check out line 40 in the code:
Code:
Set rngFound = .Range("A:A").Find(fileInFolder.Name)

If should be this:
Code:
Set rngFound = .Range("A:A").Find(what:=fileInFolder.Name, lookat:=xlWhole)

Previous line of code allowed a partial match to be found. So, when you already had found a file called
10ValidoValoresAtualizadosdoWACC120313.pdf

and then it looked for "13.pdf"

it found a partial match and was counting it. :( By changing the code to say look at whole cell, that issue should be resolved.
Worked like a charm :) Thanks!
 
Back
Top