Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Open CSV file



I need to open a CSV file in Excel 2000, find the end of the file and select
that range and copy it to spreadsheet "B" starting at A2. I am using the
following to open the file. How can I find the end of the range of a CSV
file, then copy that range to an excel sheet.

Thanks


sfile1 = Application.GetOpenFilename("Text Files (*.csv), *.txt")
If sfile1 < "" Then
Open sfile1 For Input As 1
End If


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Open CSV file

I would just open it as a workbook and then copy the used range

dim sFile1 as variant
dim destCell as range
dim wkbkCSV as workbook
sfile1 = Application.GetOpenFilename("CSV Files, *.csv")
if sfile1 = false then
exit sub
end if

set destcell = workbooks("b.xls").worksheets("somenameHere").rang e("A2")

set wkbkcsv = Workbooks.Open(Filename:=sfile1)

wkbkcsv.worksheets(1).usedrange.copy _
destination:=destcell

wkbkcsv.close savechanges:=false

======
Uncompiled, untested--watch for typos!



Striker wrote:

I need to open a CSV file in Excel 2000, find the end of the file and select
that range and copy it to spreadsheet "B" starting at A2. I am using the
following to open the file. How can I find the end of the range of a CSV
file, then copy that range to an excel sheet.

Thanks

sfile1 = Application.GetOpenFilename("Text Files (*.csv), *.txt")
If sfile1 < "" Then
Open sfile1 For Input As 1
End If


--

Dave Peterson
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
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Excel Discussion (Misc queries) 0 April 23rd 09 08:53 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM


All times are GMT +1. The time now is 09:41 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"