+ Reply to Thread
Results 1 to 5 of 5

Loop through files and use the filename without extension

  1. #1
    Registered User
    Join Date
    12-18-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    24

    Loop through files and use the filename without extension

    Hello everyone,

    My problem is the following:
    I got a directory with a set of .csv files. I want to loop through these files and everytime take the name of each file without extension and put it in a cell in Sheet1(the cell has to increase by 1)
    So lets say: 01.csv takes the 01 and place it in C12, 02.csv -> C13 etc until it finds and empty row.
    My goal is to look like the following:

    Cells || Number of Csv ||| Voltage
    C12 || 01 ||| 2kV
    C13 || 02 ||| 4kV
    C14 || 03 ||| 6kV
    C15 || 04 ||| 8kV
    Empty row===============================
    Cells || Number of Csv ||| Voltage
    C18 || 05 ||| 2kV
    C19 || 06 ||| 4kV
    C20 || 07 ||| 6kV
    C21 || 08 ||| 8kV

    I use the following code for the first group 01 to 04. I guess the same has to be used for C18:C21
    Please Login or Register  to view this content.
    With the above code my problem is that it pastes always the 01. So i guess i need something like file=file+1 to take the next file but obviously this doesn't work :P
    Thank you for your help in advance !
    Last edited by desolatori; 02-06-2014 at 05:26 AM.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Loop through files and use the filename without extension

    Made some amendments, see if this helps?
    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    12-18-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Loop through files and use the filename without extension

    Thank you for the quick reply. Yeah it works if there are 8 files in the directory. If there are more it crashes the excel. Can this work with a more dynamic way and perform the same independently from the number of csv which are inside the directory?

    Thank you again!

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Loop through files and use the filename without extension

    How about this?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-18-2013
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Loop through files and use the filename without extension

    It works like a charm, Thank you

+ 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. [SOLVED] Getting filename without extension and seperating the value based on a character
    By szpt9m in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2014, 02:17 AM
  2. Formula to show the Filename (without path/extension) in a cell
    By acsishere in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-01-2013, 09:33 AM
  3. Windows XP : Delete extension of filename
    By london7871 in forum Microsoft Windows Help
    Replies: 3
    Last Post: 12-22-2011, 09:38 AM
  4. Excel 2007 : remove extension in header filename
    By Rob44 in forum Excel General
    Replies: 0
    Last Post: 10-24-2011, 07:07 PM
  5. Getting only the filename with no extension
    By Barry Clark in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2006, 02:55 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