+ Reply to Thread
Results 1 to 3 of 3

When opening book, write all filenames of the directory to cells

  1. #1
    Registered User
    Join Date
    10-11-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    38

    When opening book, write all filenames of the directory to cells

    Hello everyone

    I am new to VBA and face a problem I think does not work without it anymore.

    The situation is as follows:

    Working directory: "C:\work"

    Main file (only file open): "main.xlsx"

    Additional files (growing every week to around 100):
    "A.xlsx"
    "B.xlsx"
    "C.xlsx"
    ...

    What do I want?

    I want that whenever I start main.xlsx, the current filenames of the files are written into specific cells of a sheet in main.xlsx.

    It would be nice to omit "main.xlsx" in the process.

    I found a fast looping code on stackoverflow.com:

    Sub LoopThroughFiles()
    Dim StrFile As String
    StrFile = Dir("c:\testfolder\*test*")
    Do While Len(StrFile) > 0
    Debug.Print StrFile
    StrFile = Dir
    Loop
    End Sub

    Maybe there is someone who could help me to make this work?

    Thank you very much!
    Regards
    Last edited by nivoe; 11-08-2012 at 10:10 AM. Reason: uploaded wrong code

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: When opening book, write all filenames of the directory to cells

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    10-11-2012
    Location
    switzerland
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: When opening book, write all filenames of the directory to cells

    Ok, thank you, it's working!

    I am trying to make it more detailed now on my own ... have to learn VBA now

    But thanks for the start, I really appreciate it.


+ 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