LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Copying unlimited range of data and closing the file

That sounds like you throw away the previous data and start anew each day.

The new log file replaces the existing sheet 2 in your excel file.

I'm not sure what the name of the sheet2 is, but you could delete it first:

application.displayalerts = false
Workbooks("Import ProE Log.xls").Sheets("sheet2").delete
application.displayalerts = true

Then MOVE that imported worksheet to where you want it:

Activesheet.Move _
Befo=Workbooks("Import ProE Log.xls").Sheets(1)
activesheet.name = "Sheet2"

Right after you open that .csv file, it's the activesheet.

And it'll still be active when it hits the "import Proe log.xls" workbook.

Then..
With worksheets("sheet2")
.range("a1").resize(2,1).entirerow.insert
'to make room for the headers
end with

===================
Another option (if you aren't too confused already). Just copy that used range
to the existing worksheet starting in A3.

'clear out old data
Workbooks("Import ProE Log.xls").Sheets("sheet2").range("A3:IV65536").cle ar

Workbooks.OpenText Filename:= .....

activesheet.usedrange.copy _
destination:=Workbooks("Import ProE Log.xls").Sheets("sheet2").range("a3")

''''
and the headers won't need to be added.

============
Try changing mudraker's .paste line to: .PasteSpecial xlValues
or
Rows("1:" & GetBottomRow).Copy _
destination:=Workbooks("Import ProE Log.xls").Sheets(1).Range("a3")

(Yeah, there's lots of ways to skin that cat!)

Good luck,








"morry <" wrote:

Thank you for the code mudraker but when I ran it it gave me and error
(object doesn't support this method) in the line listed below. I tried
to figure it out but I couldn't get anything else to work. Do you know
whats wrong?

Workbooks("Import ProE Log.xls").Sheets(2).Range("a3").Paste

Dave - to clarify my objectives:

I have a csv log file that gets updated everyday. I also have a Excel
workbook called "Import ProE Log" I want to copy the data from the log
file, delimit it, and open it as sheet two in my workbook. I need the
data two start on row three so I can insert headers on the first rows.
I have my code in a command button so that this can be run every day.
Sorry it wasn't clear the first time.

Thank you both for your help

morry

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

 
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
Copying a range of data without adjusting formulas Captain Jack Flak Excel Discussion (Misc queries) 18 August 11th 11 08:51 AM
calculate values in an unlimited range of cells in a column WITHOUTalso calculating values that had previously been filtered AGAINST? yadang Excel Discussion (Misc queries) 2 October 1st 09 06:18 PM
Copying data from multiple file into one file nsd Excel Discussion (Misc queries) 4 September 17th 09 07:18 PM
Copying a Range of Cells having data only shriil Excel Worksheet Functions 3 February 8th 09 09:36 PM
Copying range format and formulae without data Kevryl Excel Discussion (Misc queries) 1 September 9th 05 01:55 PM


All times are GMT +1. The time now is 05:41 AM.

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

About Us

"It's about Microsoft Excel"