+ Reply to Thread
Results 1 to 5 of 5

Removing line breaks from .cvs file BEFORE importing

  1. #1
    Forum Contributor banaanas's Avatar
    Join Date
    08-26-2014
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    199

    Removing line breaks from .cvs file BEFORE importing

    Hi!

    I am trying to creat a macro that imports a user selected .cvs file into a new sheet called Penstream, and after that it starts copying values to other sheets.

    My problem is that somtimes the imported .cvs files has line breaks in them
    This messes up the new sheet whit the imported .cvs data, and that in return messes up the rest of my code.
    Is there a way for me to add to the macro that it removes the linebreaks from the .cvs file before it starts importing it to the main excel file?

    This is what I got so far:

    Please Login or Register  to view this content.
    Last edited by banaanas; 06-18-2015 at 06:39 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Removing line breaks from .cvs file BEFORE importing

    It is always better to keep the original files, so the code will create new file in the same folder for testing purpose.
    If you feel to replace the original file, change Replace(fn, ".csv","_NoLineBreak.csv") to just fn.
    Please Login or Register  to view this content.
    Then add one line to your sub
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor banaanas's Avatar
    Join Date
    08-26-2014
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    199

    Re: Removing line breaks from .cvs file BEFORE importing

    I get a Compile error: ByRef argument type mismatch and it highlights Sub Getpenstreamcvs()
    If I comment out RemoveLinebreakFromCSV fname then the macro will run, without your addition
    Last edited by banaanas; 06-18-2015 at 04:46 AM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Removing line breaks from .cvs file BEFORE importing

    Try change to (also a type found)
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor banaanas's Avatar
    Join Date
    08-26-2014
    Location
    Finland
    MS-Off Ver
    2016
    Posts
    199

    Re: Removing line breaks from .cvs file BEFORE importing

    Yup now it is working, thank you a million times!

+ 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] Removing Internal Cell Line Breaks to columns
    By Aussie909 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-17-2014, 06:48 PM
  2. [SOLVED] Removing unnecessary line breaks after the texts
    By groqkorn in forum Excel General
    Replies: 8
    Last Post: 11-20-2012, 10:15 PM
  3. Problem importing a CSV into Excel with Line Breaks
    By FirstCapitol in forum Excel General
    Replies: 2
    Last Post: 04-01-2009, 01:26 PM
  4. Removing Line Breaks In A Cell
    By Ross220681 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-10-2009, 11:14 AM
  5. Replies: 1
    Last Post: 01-18-2008, 07:02 AM

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