0
votes

I am trying to copy some ranges of data from multiple Excel files and paste (by appending) into a single csv file. So, to append the data, I need to locate the last row in the csv file. Is the way to locate the last row number in csv different the way to locate the last row number in excel as below? Cells(Rows.Count, "a").End(xlUp) If so, How can I locate the last row in csv? or do you have any suggestion in how to append ranges of data from different Excel files into a single csv file?

Thank you very much,

1
How do you handle CSV? via ADODB or whatever else? Showing up your code will be very helpful.Peter L.
Once the .csv file is open it should behave ilke any other Excel file. Instead of just asking, did you try your method? I think it should work. If it doesn't - edit your answer, and show us what happened.Floris
A csv file is just a plain text file. Properly formatted, it has no "rows" beyond the last line of data.Tim Williams

1 Answers

0
votes

A good way of doing this is cells(1048576,1).end(xlup).row. this will give you the last row which is not blank in the first column. For this, you have to be sure that the first column is not empty and that it contains data. '1048576' is the last row in excel 2010. in 2007, it is somewhere around 600000. so change it accordingly based on your version of excel.

If you are appending data then use this

Cells(Cells(1048576, 1).End(xlUp).Row + 1, 1).Select
Activesheet.paste

Hope this helps.