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
 Origin Forum
 Help manipulating worksheet columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cyantist

USA
8 Posts

Posted - 02/23/2010 :  08:23:34 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 7.5
Operating System: Windows XP

I'd like to automate the following task and would need some help:

I need to move specific columns from 1 worksheet to new (created or existing)worksheets. For example, if in the main worksheet, I have 5 columns, I'd like to distribute each of the 5 columns into designated columns in separate worksheets, thereby creating 5 new worksheets. I will have more than 1 column from the main worksheet that needs to be distributed and copied amongst the newly created worksheets, i.e., each newly created worksheet will have several columns of data copied from the main worksheet.

In summary:

Need to move Columns ABCXYZ in Main Worksheet to --

Col A and Col X --> New Worksheet 1
Col B and Col Y --> New Worksheet 2
Col C and Col Z --> New Worksheet 3

Thanks in advance for your kind help.

vincenth

30 Posts

Posted - 02/23/2010 :  4:50:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Automate this task using a LabTalk script. From the "Window" drop-down menu, select "Script Window" to open the script window.

Enter the following (// preceeds a comment, which will not be executed) code; the text between the *******'s. It should work for the example you've described.

This code assumes your initial workbook is given the default name "data1". If not, replace "data1" in the code below with your workbook name.

*********************

win -t data Origin newdata2; // creates a new workbook named newdata2
%(newdata2,1)=%(data1,1); // copies data1/col1 to newdata2/col1
%(newdata2,2)=%(data1,4); // copies data1/col4 to newdata2/col1

// Now repeat for the other columns

win -t data Origin newdata3;
%(newdata3,1)=%(data1,2);
%(newdata3,2)=%(data1,5);

win -t data Origin newdata4;
%(newdata4,1)=%(data1,3);
%(newdata4,2)=%(data1,6);

***********************

Now highlight the code above with your cursor and hit enter. This should perform the desired task.

If you want to know more about scripting in Origin, see the LabTalk Scripting Guide available on our public Wiki: http://wiki.originlab.com/~originla/wiki/index.php?title=Category:LabTalk_Programming

Note that many of the latest features in LabTalk are available only in Origin 8.0 and Origin 8.1.

I hope this is helpful,
Vince H
OriginLab Corp.
Go to Top of Page

cyantist

USA
8 Posts

Posted - 02/23/2010 :  10:30:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks very much, Vince! :)
Go to Top of Page

cyantist

USA
8 Posts

Posted - 02/25/2010 :  3:40:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Follow-up Q:

How can I designate column names (labels) in the newly created worksheet columns? Would it be better to create the worksheets as a template before copying data?
Go to Top of Page

cyantist

USA
8 Posts

Posted - 02/25/2010 :  6:40:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This does not automatically add columns in the new worksheets beyond the first 2. Is this an issue of Origin version (I'm at 7.5)?

win -t data Origin newdata2; // creates a new workbook named newdata2
%(newdata2,1)=%(data1,1); // copies data1/col1 to newdata2/col1
%(newdata2,2)=%(data1,4); // copies data1/col4 to newdata2/col1


It would be nice if I could copy identified columns into created worksheets that have column labels, as in a template form. Is this possible?
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