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
 calculation across 2 worksheet s
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

fastelectron

India
5 Posts

Posted - 07/26/2013 :  02:44:18 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. : 8.5
Service Release : SR1
Operating System: Windows 7

Hi ,

I am facing a tedious task in some calculation.

I have 2 worksheets, say A and B.

A has 2 cols and n rows.

B has n+1 cols and ~150 rows. (1st col X and the rest all Y)

Now I need to divide the first col and each subsequent col of B
with each row values of A.

ie,

xn = B(1st col) / A(n row,1 col)

and

yn = B(nth col) / A(n row,2 col)

for all values of n.

I am having 8 such (A,B) pairs of worksheets, and I am already
crossing all the limits of sanity.

somebody plz save me.

thanks alot

-S.

---

Penn

China
644 Posts

Posted - 08/01/2013 :  11:12:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If I have understood what you want, the following LabTalk script can be referred to. This script will create a new workbook for the output data. For each column in sheet B, it will be divided by each row value in column 1 or 2 in sheet A, that is to say, if there are n rows in sheet A, there will be n output columns for each column in sheet B. So the number of columns in the output sheet will be the number of columns in sheet B multiplied by n.

int n = 5;  // n rows in A, n+1 columns in B
range rAcol1 = [book1]A!col(1);  // assume sheet A's book is book1, range to column 1
range rAcol2 = [book1]A!col(2);  // assume sheet B's book is book1, range to column 2
range rB = [book1]B!;  // range to sheet B
newbook;  // create a new book for the output data
wks.nCols = rB.nCols*n;  // set the number of columns in the output sheet (active one)
for(int ii = 1; ii <= n; ii++)  // n rows
{
	for(int jj = 1; jj <= n+1; jj++)  // n+1 columns
	{
		range rBcoljj = [book1]B!wcol(jj);  // column jj in sheet B
		if(jj == 1)  // x column
		{
			wcol(jj+(ii-1)*(n+1)) = rBcoljj/rAcol1[ii];
			wks.col$(jj+(ii-1)*(n+1)).type = 4;  // set as x column
		}
		else  // y column
		{
			wcol(jj+(ii-1)*(n+1)) = rBcoljj/rAcol2[ii];
		}
	}
}


Penn
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