ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy from CSV (https://www.excelbanter.com/excel-programming/423119-copy-csv.html)

thanks

Copy from CSV
 
Hello
I am trying to open a CSV file and copy portions from it. I would like to
open
\\mypath\myfile.csv then copy B3:Y3 to my other file sheet1 B5:Y5.
Could someone please help?





thanks

Copy from CSV
 
I recorded this macro

Workbooks.Open Filename:="Mypath\myfile.csv"
Range("B3:Y3").Select
Selection.Copy
Windows("MyOtherFile").Activate
Range("B5").Select
ActiveSheet.Paste

When I activate the code it works but when I copy it into another module I get
Application-defined or Object-defined error . The only difference is that
the 2 files are not in the same directory.


"Thanks" wrote:

Hello
I am trying to open a CSV file and copy portions from it. I would like to
open
\\mypath\myfile.csv then copy B3:Y3 to my other file sheet1 B5:Y5.
Could someone please help?





Gary''s Student

Copy from CSV
 
1. start with your original workbook
2. turn on the recorder
3. Data Import External Data Import Data
(tell the Wizard where the .csv file is and tell the Wizard to make a new
sheet)
4. copy the desired data from the new sheet to the original sheet
5. turn off the recorder


Using the Import Wizard means that you do not have to deal with two open
workbooks, only two worksheets.
--
Gary''s Student - gsnu200829


"Thanks" wrote:

I recorded this macro

Workbooks.Open Filename:="Mypath\myfile.csv"
Range("B3:Y3").Select
Selection.Copy
Windows("MyOtherFile").Activate
Range("B5").Select
ActiveSheet.Paste

When I activate the code it works but when I copy it into another module I get
Application-defined or Object-defined error . The only difference is that
the 2 files are not in the same directory.


"Thanks" wrote:

Hello
I am trying to open a CSV file and copy portions from it. I would like to
open
\\mypath\myfile.csv then copy B3:Y3 to my other file sheet1 B5:Y5.
Could someone please help?






All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com