Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Help with an error in a csv file

I have been searching for a routine to solve a problem, I know somebody has to
have solved this before, no luck.

I am trying to import a csv file. The file is 10k+ lines long. Every so often
in those lines, there is an extra comma in the original csv file. This, of
course, causes that line to end up with a blank cell, the rest of the cells to
the right are out of alignment with all the other cells. This can happen
anywhere from once or twice to hundreds of times per csv. The csv is supplied
to me by another company, having them fix the original error is out of the
question. Ultimately, a non-technical person is going to end up with this
solution, so while I could just fix the problem myself by manually cutting and
pasting, I don't want to rely on the user doing this every week, hence the need
for a vba macro.

The blank cell occurs in column K. I can get all the data sorted so that the
blanks in column K are sorted to the top, with the blank starting at K1.

So the logic would go:

Start in cell K1.
If cell K1 is not blank, stop the macro.
If K1 is blank, cut range L1:AI1, paste into range K1:AH1, ignoring the message
about overwriting existing data. Move to cell K2 and repeat, if cell K2 is not
blank, stop the macro, etc.

Once I get the data back in line, I think I can handle what I need from that
point forward.

I am using Excel 2003.

Many thanks in advance for any assistance you are able to provide!!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help with an error in a csv file

If there are not supposed to be any empty cells in the data after you've
imported the CSV file, you may want to try this.

Edit|goto|special|blank cells
Edit|delete
Shift cells right

If you can have empty cells in the data, you could select column K and then use
the same technique.

Melvin Purvis wrote:

I have been searching for a routine to solve a problem, I know somebody has to
have solved this before, no luck.

I am trying to import a csv file. The file is 10k+ lines long. Every so often
in those lines, there is an extra comma in the original csv file. This, of
course, causes that line to end up with a blank cell, the rest of the cells to
the right are out of alignment with all the other cells. This can happen
anywhere from once or twice to hundreds of times per csv. The csv is supplied
to me by another company, having them fix the original error is out of the
question. Ultimately, a non-technical person is going to end up with this
solution, so while I could just fix the problem myself by manually cutting and
pasting, I don't want to rely on the user doing this every week, hence the need
for a vba macro.

The blank cell occurs in column K. I can get all the data sorted so that the
blanks in column K are sorted to the top, with the blank starting at K1.

So the logic would go:

Start in cell K1.
If cell K1 is not blank, stop the macro.
If K1 is blank, cut range L1:AI1, paste into range K1:AH1, ignoring the message
about overwriting existing data. Move to cell K2 and repeat, if cell K2 is not
blank, stop the macro, etc.

Once I get the data back in line, I think I can handle what I need from that
point forward.

I am using Excel 2003.

Many thanks in advance for any assistance you are able to provide!!!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Help with an error in a csv file

Dave Peterson wrote:
If there are not supposed to be any empty cells in the data after you've
imported the CSV file, you may want to try this.

Edit|goto|special|blank cells
Edit|delete
Shift cells right

If you can have empty cells in the data, you could select column K and then use
the same technique.


Many thanks for your quick reply!

DUH, no wonder I couldn't find any help on my own, I was trying to make the
solution far too difficult.

i am getting the project whittled down to size, but I have 2 more questions
which I will post under separate subjects...

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 - error saving file & error loading dll TinaF Excel Discussion (Misc queries) 0 July 1st 09 01:49 PM
Run-time error 75 Path/File access error Casey[_89_] Excel Programming 2 May 9th 06 07:20 PM
Path/File access error (Error 75) using Name Statement blayne Excel Programming 7 November 22nd 05 09:20 PM
Path/File access error (Error 75) after using Name Statement blayne Excel Programming 0 November 10th 05 12:33 AM
Error:Invalid File format,while opening an Excel Template file Saurabh Excel Programming 1 January 17th 05 07:15 AM


All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"