T O P I C R E V I E W |
cyantist |
Posted - 02/23/2010 : 08:23:34 AM 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. |
4 L A T E S T R E P L I E S (Newest First) |
cyantist |
Posted - 02/25/2010 : 6:40:50 PM 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? |
cyantist |
Posted - 02/25/2010 : 3:40:01 PM 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? |
cyantist |
Posted - 02/23/2010 : 10:30:03 PM Thanks very much, Vince! :) |
vincenth |
Posted - 02/23/2010 : 4:50:37 PM 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. |
|
|