Results 1 to 4 of 4

Rename csv file without losing its columns format

Threaded View

  1. #1
    Registered User
    Join Date
    02-19-2018
    Location
    Czech Republic
    MS-Off Ver
    Excel 2016
    Posts
    68

    Rename csv file without losing its columns format

    Hi all,

    I have a macro that is taking the complete path and name of a .csv file that is in A4 and then is making a copy of that file and save it to another location and also renames the csv file.

    The problem I have is, that the new csv file created is a mess. All the values I had in individual columns in the original file, appear all together in one column in the new file....

    Is there a way to keep the same csv column organization from the original file to the new one please?

    By the way, it is a must to copy and paste the file to another location without opening the original file, because it might be in use. I say this because surfing the net I saw other macros that are opening and saving as the file, but I can't do this.

    I attach you my actual code

    Sub CopyAndRenameFile()
    
    Dim oFSO As Object
    Dim FilePathAndName As String
    'Takes the path and name of csv file in A4
    FilePathAndName = Sheets("Sheet1").Range("A4")
    
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    'Copy the file in A4 and save it and rename it to another location 
    Call oFSO.CopyFile(FilePathAndName, "C:\Users\user\Desktop\Data.csv")
    
    
    End Sub
    Last edited by thorblow; 07-04-2023 at 04:39 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Combining 2 columns into one without losing its format
    By fen-fen in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-25-2022, 12:36 AM
  2. I am losing the format of a column when I ...
    By mrnoonan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-21-2020, 01:41 AM
  3. Converting from the 1904 date format to the 1900 date format without losing data
    By Patty McJorst in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-01-2020, 12:53 PM
  4. Copy chart and losing the format
    By wietzek in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-04-2019, 01:22 PM
  5. 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
  6. Vba losing date format
    By Danny.Smythe in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 08-20-2015, 11:58 AM
  7. Losing format because of multiple IF statements
    By TJC123 in forum Excel General
    Replies: 4
    Last Post: 11-01-2008, 10:43 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