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
 sum over range in "unknown" number of sheets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

OndrejMM

Australia
81 Posts

Posted - 01/19/2009 :  6:28:45 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi All

I have very simple problem, … and actually I don’t know why it doesn’t work in my way, … probably some stupid error,… so here is the problem:

I have a number of BOOKS (book1, book2,… book99) and each book contains an “unknown” number of SHEETS some of them with the names “sheet1, sheet2, … sheet99”, and I need to sum a range of cells in every sheet and type it in the command window,… so I did the following but it doesn’t work:

doc -e W { //loop over all worksheets
if( "%[%H,5]"=="sheet" ) //chose only those starting with “sheet”
{
range xx = col(d)[1:10]; //define a range col(d) row 1 to 10
sum(xx); //do the sum over the defined range
sm = sum.total; // assign the sum.total to “sm” variable
type $(sm); // print the result in command window
};
};

Thanks for your help.
Ondrej

Deanna

China
Posts

Posted - 01/19/2009 :  10:11:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In Origin 8, doc -e w loops over all workbooks instead of worksheets. In addition, %[string], nn returns all letters to the left of the specified character position. So, %[%H,5] returns the first 4 characters.

You can try my script below:

doc -e W { //Loop over all workbooks
	for (ii=1; ii<=page.nLayers; ii++)  //loop over all layers (worksheets)
	{
		page.active = ii;	//make the worksheet active
		%a=page.active$;
		if( %[%a,6]=="sheet" ) //choose only those starting with ¡°sheet¡±
		{
			stats col(d)[1:10]; // This X-Function can take the range directly
			type $(stats.sum); // print the result in command window
		};
	};
}


Deanna
OriginLab Technical Services

Edited by - Deanna on 01/19/2009 10:12:42 PM
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 01/19/2009 :  11:55:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Deanna,... works great!
Cheers, Ondrej
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