ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete first line From CSV file from excel (https://www.excelbanter.com/excel-programming/414185-delete-first-line-csv-file-excel.html)

JA[_4_]

Delete first line From CSV file from excel
 

I am modifying a csv file from VBA and am adding a line to the beginning of
file which is working well. However, I'd like to delete teh first line of
the csv file before adding the line.

I have many files so it is not efficient to open them from excel. I'd like
to use the VBA Put, Print, Write statements etc.




Rick Rothstein \(MVP - VB\)[_2335_]

Delete first line From CSV file from excel
 
I presume you are using the code that RB Smissaert posted in response to
your "how do I add a line" request. If so, add this line immediately after
you load the file into the FileContents variable (that is, make the
following the next line after the **first** Close #hFile statement...

FileContents = Mid$(FileContents, InStr(FileContents, vbCrLf) + 2)

Rick


"JA" wrote in message
...

I am modifying a csv file from VBA and am adding a line to the beginning
of file which is working well. However, I'd like to delete teh first line
of the csv file before adding the line.

I have many files so it is not efficient to open them from excel. I'd
like to use the VBA Put, Print, Write statements etc.






All times are GMT +1. The time now is 09:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com