+ Reply to Thread
Results 1 to 13 of 13

VB Code to count number of dated pdf file in folder

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to count number of dated pdf file in folder

    Hello:

    I need VB Code to do the followings.

    I have folder C:\Reports\

    Then i have subfolders

    C:\Reports\Store1\Recpt\
    C:\Reports\Store2\Recpt\
    C:\Reports\Store3\Recpt\
    C:\Reports\Store4\Recpt\
    C:\Reports\Store5\Recpt\

    and so on..

    Each of these \Recpt\ folders have pdf reports starting with MM-YYYY.
    Please refer to attached file.
    I need Code to count # of monthly files for each store and put in column B,C,D, E and so on.

    For Example i have for Store1 i have 3 files starting with 01-2016 so i will have 3 in cell B2.


    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,517

    Re: VB Code to count number of dated pdf file in folder

    Here's one way...Tests fine provided you store the file housing this code in reports folder...
    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    01-03-2018
    Location
    Fukuoka, Japan
    MS-Off Ver
    Excel 2013
    Posts
    123

    Re: VB Code to count number of dated pdf file in folder

    This is my version. How's it?

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to count number of dated pdf file in folder

    Hello Guys:

    Don't seems to work.
    My logic is to go thru each \Recpt\ folder for each store stored in row 1 of the file and look/count # of pdf file starting with text in column A and add the result in corresponding store column.
    Please let me know if you have any questions.
    Thanks.

    Riz

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,517

    Re: VB Code to count number of dated pdf file in folder

    Hi Riz

    Although both tests fine, yujin code must simpler...Why do you say the code does not work?

  6. #6
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to count number of dated pdf file in folder

    Hello:

    I like yujin code but it does not do what it suppose to do.
    It keeps on looping with the same result, total # of pdf file in a folder and the code needs to go thru each Store in row2 and put the result for the MM-YYYY shown in column A.
    Need code to pick up "StoreName" and "MonthYear"
    Please let me know if you have any questions.
    Thanks.

    Riz

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,517

    Re: VB Code to count number of dated pdf file in folder

    Riz, i have tested and both codes work

  8. #8
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to count number of dated pdf file in folder

    Hello:

    Would you mind if you can upload your test file.
    I like to see the configuration and how the code is working.
    Thanks
    Riz

  9. #9
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,517

    Re: VB Code to count number of dated pdf file in folder

    Am using your upload in Post #1
    This also works...
    NB Store the file housing this code in reports folder.
    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to count number of dated pdf file in folder

    Hello sintek:

    It works, thanks a lot.
    However, what i am seeing is if i run the macro 2 times then it adds up the number instead of fresh number.
    Example :
    I have 4 pdf file in folder,,,Run the macro it gives 4 in correct cell
    Now if i run the macro again it gives 8 although the number of pdf file is still 4

    Please help and send corrected code.

    Thanks a lot

    Riz

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,517

    Re: VB Code to count number of dated pdf file in folder

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to count number of dated pdf file in folder

    Hello:

    Thanks a lot, works

    Riz

  13. #13
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,517

    Re: VB Code to count number of dated pdf file in folder

    Glad you got it sorted...Pls mark thread as solved...tx 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. Replies: 2
    Last Post: 12-29-2015, 04:19 AM
  2. [SOLVED] Create Dated Folder with Subfolder from Cell Values
    By bloomingcarrot in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-21-2014, 05:53 PM
  3. [SOLVED] vba to open recent dated file in a folder
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-10-2014, 08:47 AM
  4. vba code to open last dated file
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2014, 07:08 PM
  5. Replies: 2
    Last Post: 11-12-2013, 02:11 AM
  6. Open multiple dated text files and import dated data specified in file name
    By andygxxxv in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-21-2013, 03:56 PM
  7. Replies: 1
    Last Post: 02-24-2006, 02:10 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