Results 1 to 5 of 5

Getting Number of excel files inside different directories

Threaded View

  1. #1
    Registered User
    Join Date
    10-27-2022
    Location
    Lisbon
    MS-Off Ver
    Microsoft 365
    Posts
    2

    Question Getting Number of excel files inside different directories

    Hello

    My goal is to have a table where Column A is a independent entity, Column B is a number dependent on the number of files from a certain folder, Column C is the directory of the certain folder.

    ____
    For vizualization aid you can Imagine:
    Column A is a store (ex: Portuguese Store)
    Column C is a directory where every individual sale is stored as an excel document
    Columb B is the cell that will reveal the number of excel files (sales) inside the directory specified in column C

    Q:
    Trying to understand how I can add more stores and directories inside the same code
    ____


    I have a innitial draft for this but I can only get the number of files for one directory, if I try to reuse the variable to get the number of files for the following directories I find a bug.

    Draft:

    Sub CountFiles()
    Dim folder_path As String
    Dim strType As String
    Dim totalfiles As Variant

    folder_path = Worksheets("Files Count").Cells(2, 3).Value

    If Right(folder_path, 1) <> "" Then folder_path = folder_path & ""
    totalfiles = Dir(folder_path & strType)

    Dim i As Integer

    While (totalfiles <> "")
    i = i + 1
    totalfiles = Dir
    Wend
    Worksheets("Files Count").Cells(2, 2).Value = i

    End Sub


    How can I edit this code so that I can add as many directories and results as I need?
    Last edited by CntrlAltDel; 10-27-2022 at 04:00 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Embedding Picture Files as Pop ups inside Excel Files
    By cmf0106 in forum Excel General
    Replies: 13
    Last Post: 06-08-2021, 11:53 PM
  2. Excel VBA: Search folder and sub-directories for files matching partial string
    By terriertrip in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-16-2020, 03:27 PM
  3. Combine excel files named Final in all sub directories into one file
    By Vadimchik in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-28-2020, 01:00 PM
  4. VBA code required to count the number of files in multipe directories.
    By yaash in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2013, 05:43 AM
  5. Replies: 2
    Last Post: 03-09-2010, 09:54 AM
  6. [SOLVED] Renaming files from a number string inside the file.
    By Gordon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2006, 01:10 PM
  7. [SOLVED] How do I get excel files to open automatically from directories?
    By Damian in forum Excel General
    Replies: 2
    Last Post: 01-03-2006, 10:55 AM

Tags for this Thread

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