View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
rhhince[_2_] rhhince[_2_] is offline
external usenet poster
 
Posts: 48
Default Macro to open CSV files

On Monday, April 1, 2013 12:27:54 AM UTC-5, wrote:
On Sunday, March 31, 2013 10:14:41 PM UTC-7, rhhince wrote:

I wish to open CSV files and grab only the last 5000 lines of it to copy and paste in another xls file. Example: I open a CSV that has 5250 rows of data, but I only wish to copy the last 5000 rows. I am forced to delete the top 250 rows before being able to copy the 5000 rows of data. Is there a macro command to simply go to the bottom and grab those last 5000 rows to copy.




Hi rhhince,

A bit clunky but try something like this.



Option Explicit



Sub AllButTwoFiveOh()

Range("A10000").End(xlUp).Offset(-5000, 0).Resize(5000, 1).Copy Range("F1")

End Sub



Regards,

Howard


Actually the CSV file changes often. Sometimes 5500 or 5850, but which to only grab the last 5000. That would not work, but thnaks.