The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Copying columns from one worksheet to another
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Nick.Thissen

Netherlands
2 Posts

Posted - 11/15/2011 :  1:12:47 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I am quite new to Origin scripting / programming, but I've already managed to get a couple things up and running such as creating workbooks and worksheets.

Now the next step requires me to copy some data from one worksheet to another worksheet (in a different workbook). I need to create the workbooks and worksheets in the script too (but as I said I know how to do that, using 'newbook' and 'newsheet').
What I can't figure out is how to copy entire columns of data from one worksheet to another.


Suppose I have one large workbook called "master_workbook" with a large number of worksheets called "sheet1" to "sheet15". Suppose also I just created a new workbook called "WB3", and in that a new worksheet called "data" (ignore the default worksheet for the moment):
newbook WB3;
newsheet name:="data";


How do I now copy the data in column C of "sheet13" in workbook "master_workbook" to column A of my newly created "data" worksheet in workbook "WB3" ?

This greatly simplifies what I need to do, obviously (otherwise I'd do it manually), but if I can just figure this step out I'm sure I can get the rest myself.

So all I need is to know how I can copy the data from one column in one worksheet to another column in another worksheet (and in another workbook), assuming I have all these:
- the name of the source workbook (master_workbook)
- the name of the source worksheet (sheet13)
- the name of the source column (C)
- the name of the destination workbook (WB3)
- the name of the destination worksheet (data)
- the name of the destination column (A)


This should not be very hard, right? I can't find much help on "copying data" let alone from one worksheet to the other. Perhaps I'm using the wrong search terms... Can anyone assist me with this?

Thanks!

Sam Fang

293 Posts

Posted - 11/16/2011 :  06:07:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use Origin's range. e.g
-------------------------------------------------------------------
range r1=[master_workbook]sheet13!col(C);
range r2=[WB3]data!col(A);
r2=r1;

-------------------------------------------------------------------

In fact Origin provides an X-Function wrcopy, it may be easier.

Sam
OriginLab Technical Services

Edited by - Sam Fang on 11/16/2011 7:43:19 PM
Go to Top of Page

Nick.Thissen

Netherlands
2 Posts

Posted - 11/16/2011 :  08:21:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, that works. What a strange syntax though, I would expect r1 and r2 to behave as variables and that "r2 = r1" would simply assign r1 to the variable r2 (thus 'erasing' r2), but this seems to be the step where the data is copied... Strange, but as long as it works :p

Thanks!
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000