+ Reply to Thread
Results 1 to 4 of 4

Import a csv and txt file, then rename the files as "csv" and "txt"?

  1. #1
    Registered User
    Join Date
    06-26-2019
    Location
    California, US
    MS-Off Ver
    Office 365
    Posts
    36

    Import a csv and txt file, then rename the files as "csv" and "txt"?

    I would like to import a csv and a txt file as two sheets, then have the program automatically rename the csv file as "csv" and txt file as "txt"

    Right now, I have a code that imports the two files, but names them as "temp1" and "temp2". How do I have excel recognize the file types and rename it?

    Please Login or Register  to view this content.
    Edit: Removed some of the extra comments I left in the code
    Last edited by Exceloof; 08-09-2019 at 02:37 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Import a csv and txt file, then rename the files as "csv" and "txt"?

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    06-26-2019
    Location
    California, US
    MS-Off Ver
    Office 365
    Posts
    36

    Re: Import a csv and txt file, then rename the files as "csv" and "txt"?

    Thank you! Repped (:

    Why is there +1 in
    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Import a csv and txt file, then rename the files as "csv" and "txt"?

    Quote Originally Posted by Exceloof View Post
    Thank you! Repped (:

    Why is there +1 in
    Please Login or Register  to view this content.
    InStrRev(fname, "\") finds the position in the string of the first "\"from right to left. Everything after that position is the filename. You don't want to include the "\" in the file name so you +1

+ 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. My File Rename Macro Always Doesn't Rename the Last Three files in the list
    By Enright in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2016, 03:46 PM
  2. [SOLVED] user form used to rename files repeatedly adding prefix to file name
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-10-2014, 08:11 AM
  3. Rename cell based on file name for multiple files
    By lmolokin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2012, 05:49 PM
  4. [SOLVED] import every file in the folder and rename sheet to the imported file name
    By vivek_work in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-04-2012, 02:46 PM
  5. Rename Excel files on base of current file name
    By ali84pk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2010, 08:46 AM
  6. How Can The Macro Rename Files When The Original File Name Changes Everday
    By np123345 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-01-2008, 06:59 PM
  7. [SOLVED] How do you rename Multiple files using text from a cell in the file?
    By RandyR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-16-2005, 03:05 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