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
 Origin Forum
 maximum value of a worksheet

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
lillt91 Posted - 02/16/2018 : 05:07:26 AM
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2015G (64-bit)
Operating System:

Hi, I have a worksheet with 55 cols and 154 rows. I want the loop to run over every single column and give out the maximum value of the active worksheet. Falsely my code gives out the maximum value of the last column... Heres my script:

maxv= 848;
maxcol = 0;
maxrow = 0;

loop(ii,2,wks.ncols-1) // Loop over all columns
{

if(maxv<max(wcol(ii)))
{
maxv=max(wcol(ii));
maxcol = ii;
maxrow = limit.imax;
}
}

dlgrowcolgoto r1:=maxrow c1:=maxcol;
2   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 02/16/2018 : 10:05:46 AM
Hi lillt91,

Just another version to avoid looping though not sure how much you get the speed gain:
//////////////////////////////////////////////
ncol=wks.ncols;
wname$=%H;     //workbook name
w2m -r 0;      //convert to matrix directly
sum(%H);       //get stats of matrix
vmax=sum.max;  //max
imax=sum.imax; //max position
maxrow=int(imax/ncol)+1; //row# in wks
maxcol=imax-ncol*int(imax/ncol); //col# in wks
window -a %(wname$); //reactivate worksheet
dlgrowcolgoto r1:=$(maxrow) c1:=$(maxcol); //highlight the cell
//////////////////////////////////////////////
--Hideo Fujii
OriginLab
lillt91 Posted - 02/16/2018 : 08:09:38 AM
I found the solution:

maxv= 848;
maxcol = 0;
maxrow = 0;

loop(ii,2,wks.ncols-1) // Loop over all columns
{

limit wcol(ii);
if(maxv<max(wcol(ii)))
{
maxv = limit.ymax;
maxcol = ii;
maxrow = limit.imax;
}
}

dlgrowcolgoto r1:=$(maxrow) c1:=$(maxcol);

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