PC Review


Reply
Thread Tools Rate Thread

Copy range to / from CSV file

 
 
blackbox via OfficeKB.com
Guest
Posts: n/a
 
      14th Jun 2007
I receive a CSV file each morning and have to copy range E2:E22 and copy it
to a XLS sheet (calculator) range H2:H22 then copy I2:I22 form the XLS sheet
to a second CSV file range F2:F22.

I assume that this is probably not too difficult but not quite sure where to
begin, other than the macro would have to be in the XLS file.

Any help would be appreciated.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200706/1

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      14th Jun 2007
Start by recording a macro whilst perform those actions.
This will give you the basic code.

If the filenames remain constant, that will work.
If they change each day, check the help for GetOpenFileName and incorporate
it into your code.

NickHK

"blackbox via OfficeKB.com" <u20390@uwe> wrote in message
news:73ac6c266f472@uwe...
> I receive a CSV file each morning and have to copy range E2:E22 and copy

it
> to a XLS sheet (calculator) range H2:H22 then copy I2:I22 form the XLS

sheet
> to a second CSV file range F2:F22.
>
> I assume that this is probably not too difficult but not quite sure where

to
> begin, other than the macro would have to be in the XLS file.
>
> Any help would be appreciated.
>
> --
> Message posted via OfficeKB.com
> http://www.officekb.com/Uwe/Forums.a...mming/200706/1
>



 
Reply With Quote
 
blackbox via OfficeKB.com
Guest
Posts: n/a
 
      14th Jun 2007
I tried to record a macro copying from the CSV and pasting to the xls but got
an error message

run-time error '1004':
Paste method of Worksheet class failed

This is the code generated

Sub import()
'
' import Macro
' Macro recorded 6/14/2007 by Administrator
'

'
Range("E2").Select
ActiveSheet.Paste
End Sub

I also tried a drag and drop without any luck

NickHK wrote:
>Start by recording a macro whilst perform those actions.
>This will give you the basic code.
>
>If the filenames remain constant, that will work.
>If they change each day, check the help for GetOpenFileName and incorporate
>it into your code.
>
>NickHK
>
>> I receive a CSV file each morning and have to copy range E2:E22 and copy it
>> to a XLS sheet (calculator) range H2:H22 then copy I2:I22 form the XLS sheet

>[quoted text clipped - 4 lines]
>>
>> Any help would be appreciated.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200706/1

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      15th Jun 2007
You are opening the .csv in Excel ?
If not, then E2:E22 means nothing.

If you are opening in Excel, then the macro recorder will get the file name
and copy/paste actions.

NickHK

"blackbox via OfficeKB.com" <u20390@uwe> wrote in message
news:73afe2435aaf6@uwe...
> I tried to record a macro copying from the CSV and pasting to the xls but

got
> an error message
>
> run-time error '1004':
> Paste method of Worksheet class failed
>
> This is the code generated
>
> Sub import()
> '
> ' import Macro
> ' Macro recorded 6/14/2007 by Administrator
> '
>
> '
> Range("E2").Select
> ActiveSheet.Paste
> End Sub
>
> I also tried a drag and drop without any luck
>
> NickHK wrote:
> >Start by recording a macro whilst perform those actions.
> >This will give you the basic code.
> >
> >If the filenames remain constant, that will work.
> >If they change each day, check the help for GetOpenFileName and

incorporate
> >it into your code.
> >
> >NickHK
> >
> >> I receive a CSV file each morning and have to copy range E2:E22 and

copy it
> >> to a XLS sheet (calculator) range H2:H22 then copy I2:I22 form the XLS

sheet
> >[quoted text clipped - 4 lines]
> >>
> >> Any help would be appreciated.

>
> --
> Message posted via OfficeKB.com
> http://www.officekb.com/Uwe/Forums.a...mming/200706/1
>



 
Reply With Quote
 
blackbox via OfficeKB.com
Guest
Posts: n/a
 
      15th Jun 2007
i recorder the macro in the xls, open the csv. copied, pasted to the xls

i had hoped it would recognize the different workbooks

NickHK wrote:
>You are opening the .csv in Excel ?
>If not, then E2:E22 means nothing.
>
>If you are opening in Excel, then the macro recorder will get the file name
>and copy/paste actions.
>
>NickHK
>
>> I tried to record a macro copying from the CSV and pasting to the xls but got
>> an error message

>[quoted text clipped - 31 lines]
>> >>
>> >> Any help would be appreciated.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200706/1

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      15th Jun 2007
But do you open the csv IN Excel ?
If you open the .csv in another program before you copy, then Excel has no
way to know what you are doing.

Excel can open csv natively, in case you did not know.

NickHK

"blackbox via OfficeKB.com" <u20390@uwe> wrote in message
news:73b9bdc68ef8e@uwe...
> i recorder the macro in the xls, open the csv. copied, pasted to the xls
>
> i had hoped it would recognize the different workbooks
>
> NickHK wrote:
> >You are opening the .csv in Excel ?
> >If not, then E2:E22 means nothing.
> >
> >If you are opening in Excel, then the macro recorder will get the file

name
> >and copy/paste actions.
> >
> >NickHK
> >
> >> I tried to record a macro copying from the CSV and pasting to the xls

but got
> >> an error message

> >[quoted text clipped - 31 lines]
> >> >>
> >> >> Any help would be appreciated.

>
> --
> Message posted via OfficeKB.com
> http://www.officekb.com/Uwe/Forums.a...mming/200706/1
>



 
Reply With Quote
 
blackbox via OfficeKB.com
Guest
Posts: n/a
 
      15th Jun 2007
i do open it in excel, however I have been opening it in a second excel
window so I can view them side by side.

is that the problem?

NickHK wrote:
>But do you open the csv IN Excel ?
>If you open the .csv in another program before you copy, then Excel has no
>way to know what you are doing.
>
>Excel can open csv natively, in case you did not know.
>
>NickHK
>
>> i recorder the macro in the xls, open the csv. copied, pasted to the xls
>>

>[quoted text clipped - 13 lines]
>> >> >>
>> >> >> Any help would be appreciated.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200706/1

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      18th Jun 2007
Do you mean a second instance of Excel ?
Look in the task manager and see how many Excel you have.

Also post the code that you have for the opening and copy/paste so far.

NickHK

"blackbox via OfficeKB.com" <u20390@uwe> wrote in message
news:73c17573c07b2@uwe...
> i do open it in excel, however I have been opening it in a second excel
> window so I can view them side by side.
>
> is that the problem?
>
> NickHK wrote:
> >But do you open the csv IN Excel ?
> >If you open the .csv in another program before you copy, then Excel has

no
> >way to know what you are doing.
> >
> >Excel can open csv natively, in case you did not know.
> >
> >NickHK
> >
> >> i recorder the macro in the xls, open the csv. copied, pasted to the

xls
> >>

> >[quoted text clipped - 13 lines]
> >> >> >>
> >> >> >> Any help would be appreciated.

>
> --
> Message posted via OfficeKB.com
> http://www.officekb.com/Uwe/Forums.a...mming/200706/1
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy range to Text (Tab delimited) (*.txt) file Dan Microsoft Excel Programming 2 14th Feb 2008 08:04 PM
Copy a range of information to a worksheet in a specific file =?Utf-8?B?VGhlbyBEZWdy?= Microsoft Excel Programming 1 22nd Jun 2007 04:07 PM
look up a set of values,copy a range of data into 2nd file new_to_vba Microsoft Excel Programming 1 7th Feb 2006 04:21 PM
Copy range from closed file nc Microsoft Excel Programming 11 15th Mar 2005 06:00 PM
Copy a range from a CSV file in a webpage to my local worksheet Jav Pa Microsoft Excel Programming 4 25th Aug 2004 01:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:19 AM.