Author |
Topic  |
|
cheynitz
Germany
31 Posts |
Posted - 04/13/2023 : 04:07:57 AM
|
Origin Ver. and Service Release (Select Help-->About Origin): 2021pro Operating System: Win10
Hi everyone,
i have 10 worksheets with each x-y Data in two corresponding columns. In another workbook there is one column with 10 entries, each containing a shift value for the 10 x data-components.
How can i match the 10 shift values to apply for their corresponding x-columns? In an ideal case in every of the 10 worksheets a new column "x-shift" is generated and calculated, based on the shft value.
Thank you |
|
YimingChen
1665 Posts |
Posted - 04/13/2023 : 09:02:14 AM
|
It requires LabTalk script to handle this task. It would be helpful if you could share a project file.
James |
 |
|
cheynitz
Germany
31 Posts |
Posted - 04/20/2023 : 05:39:42 AM
|
Thank you very much James! In deed a little disappointing that there is no straight forward option for such an usual task :( |
 |
|
snowli
USA
1427 Posts |
Posted - 04/20/2023 : 11:57:33 AM
|
I think we need to know better where u need the output to. If u want to replace existing A columns, maybe writing script is faster since the script should be simple. If u just want to put all shifted X in individual columns in a new sheet, u can do the following
 Suppose all your worksheets in same book (book1) I created a new book with X shift values for each sheet in Book2. Enter formula [book1]$(j-1)!A+A1 in B formula to calculate [book1]1!A column plus A1 value in book2. Then click on the formula cell. Drag the tiny dot on bottom-right corner of the cell right, or double click the tiny dot to extend formula to the right columns.
It will show the shifted X values for all A sheets. U can also stack them into a new column.
Thanks, Snow
|
 |
|
cheynitz
Germany
31 Posts |
Posted - 04/20/2023 : 12:12:18 PM
|
Hi Snow, thank you very much for your answer, which i learned a lot from, also indepedent from my question.
In my ideal scenario the calculated x-shift columns are "added" to the existing x-y Worksheets as new columns. This would also call for coding?
Best Christian |
 |
|
snowli
USA
1427 Posts |
Posted - 04/20/2023 : 2:13:10 PM
|
Yes, if u want to add new column in each sheet with xshift value from another column in another book, u will need to loop through sheet.
U can easily do column calculation by defining range variables for different columns https://www.originlab.com/doc/en/LabTalk/guide/Range-Notation
Run the following script to add new column on each sheet of book1 and shift x.

range xshift = [book2]Sheet1!A; ii=1; doc -e lb //loop through sheets { if (%H == "Book1") //only for book1 { wks.ncols=wks.ncols+1; //add one column range rA=A; //rA is column A range rLast = 0; //0 is dynamic ending. here last column rLast = rA+xshift[$(ii)]; ii++; } }
Thanks, Snow
|
 |
|
cheynitz
Germany
31 Posts |
Posted - 04/20/2023 : 4:12:02 PM
|
Great, thank you very much! It works fine and i can comprehend the logic behind it. |
 |
|
|
Topic  |
|