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
 Multiple sheets - script window formula
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ru4n0907

Brazil
6 Posts

Posted - 10/07/2022 :  09:07:02 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
hello, I'm working with several sheets at the same time and I would like a formula in the script window to make the account in all of them at once. what I want is to calculate the ratio between two columns in these sheets and put it in another column and then get a specific value from that other column, for example: get the value of row 10 of that column where we calculated the ratio and put it in a new column . So I want a formula that does this in all sheets but 1, which would be, for example, the sheet ''values''

snowli

USA
1429 Posts

Posted - 10/07/2022 :  09:36:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use Set Column Values dialog (F(x) cell) of a column to enter formulas to do column based calculation.
https://www.youtube.com/watch?v=vAghAi0dazM

E.g. in a column, u can enter [book1]1!B/[book2]1!B to calculate ratio between column Bs of book1's 1st sheet and book2's 1st sheet, etc.
U can also use cell formula
e.g. =[Book1]1!B[10] to refers to 10th row of column B in 1st sheet of Book1.

Maybe you can share a project so we can better understand your question.

Thanks, Snow
Go to Top of Page

ru4n0907

Brazil
6 Posts

Posted - 10/07/2022 :  09:57:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
so, I have 100 other books to do this account in all of them, but manually it takes time to put the formula in one by one after getting the value of a certain row of the column, I want some command to do this in all of one time
Go to Top of Page

snowli

USA
1429 Posts

Posted - 10/07/2022 :  10:17:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, u can loop through all books in project.
https://www.originlab.com/doc/LabTalk/guide/Looping-Over-objs

When u refer to sheets of current book, u don't need to have book part in formula.

You may need to define range to refer to columns in other sheets, etc. when using Labtalk

https://www.originlab.com/doc/LabTalk/guide/Worksheet-Column-Data-Manipulation


Thanks, Snow
Go to Top of Page

ru4n0907

Brazil
6 Posts

Posted - 10/07/2022 :  11:40:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
solved it in part, how do I get 1 woorkbook out of the loop?
and then how do i pass the calculated results to another woorkbook? I'm using this:

doc -ef W
{
// Loop over all worksheets in each workbook
loop(ii,1,page.nlayers)
{
range rW = [%H]$(ii)!;
rW.addCol(Result);
newColIndex = rw.nCols;
range rA = [%H]$(ii)!col(3);
range rB = [%H]$(ii)!col(4);
range rF = [%H]$(ii)!col($(newColIndex));
range rR = [%H]$(ii)!col($(newColIndex));
rR = rA / rB;


}
}
Go to Top of Page

snowli

USA
1429 Posts

Posted - 10/07/2022 :  12:20:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Do you mean you want to exclude one book in the loop?
U can wrap

if(%H != "Book4")
{

}

around
loop(ii,1,page.nlayers)
{

}



U can use Worksheet: Append Worksheet... to pick sheets and specified columns to put them into a new book.

Thanks, Snow


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