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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 sum over range in "unknown" number of sheets

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
OndrejMM Posted - 01/19/2009 : 6:28:45 PM
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

2   L A T E S T    R E P L I E S    (Newest First)
OndrejMM Posted - 01/19/2009 : 11:55:19 PM
Thanks Deanna,... works great!
Cheers, Ondrej
Deanna Posted - 01/19/2009 : 10:11:18 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000