Author |
Topic |
|
Nackter Walter
7 Posts |
Posted - 03/31/2017 : 09:49:42 AM
|
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2016, b).3.226 Operating System: Windows server 2012R2
Hello,
I got some easy task and i don't know what I'am doing wrong. I want to sum up every column in my worksheet and show the result in the next free row for each column. I got almost no skill in programming and I don't know why only the first row of my data is shown in the result. Here is my skript:
for(mm=2;mm<=25;mm++) { range aa=col($(mm)); sum (aa); cell(30,$(mm))=aa; } cell(30,1)="sum"
This is how my data look like after running through the skript:
Best regards, Jan |
|
Hideo Fujii
USA
1582 Posts |
Posted - 03/31/2017 : 3:27:37 PM
|
Hi Jan,
Does the following work?//////////////////////////////
nr=wks.maxrows; //# of rows
nc=wks.nCols; //# of cols
for(mm=2;mm<=nc;mm++) {
range aa=wcol(mm)[1-nr];
sum(aa);
cell((nr+1),mm)=sum.total;
}
cell((nr+1),1)="sum";
////////////////////////////// I hope this works.
--Hideo Fujii OriginLab |
|
|
Nackter Walter
7 Posts |
Posted - 04/03/2017 : 11:41:20 AM
|
Thank you for your answer but this code don't work too. The result can be seen in the following:
|
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 04/03/2017 : 12:44:12 PM
|
Hi Jan,
Sorry, it seems that Origin 2016's Sum function doesn't accept the row-limited range as the argument. (It works in Origin 2017.) So, you can just remove [1-nr] in the range declaration of aa such as:nr=wks.maxrows; //# of rows
nc=wks.nCols; //# of cols
for(mm=2;mm<=nc;mm++) {
range aa=wcol(mm);
sum(aa);
cell((nr+1),mm)=sum.total;
}
cell((nr+1),1)="sum"; I hope this now works.
--Hideo Fujii OriginLab |
Edited by - Hideo Fujii on 04/03/2017 12:45:28 PM |
|
|
Nackter Walter
7 Posts |
Posted - 04/04/2017 : 03:57:40 AM
|
I have also tried this yesterday, but this isn't working too. |
|
|
Hideo Fujii
USA
1582 Posts |
Posted - 04/04/2017 : 10:16:46 AM
|
Hi Nackter Walter,
As far as I tried this revised code, it works in Origin ver. 2016(Sr2), and ver. 2015. So, I don't know why it didn't work in your Origin. When you run the code, is the worksheet active (at top most) as it should be? Also, did you get error message, or something? Saying simply "this isn't working" doesn't help me to understand your situation. As the last resort, please send your Origin file with the description what you did to tech@originlab.com with Subject:ATTN.Hideo .
--Hideo Fujii OriginLab |
Edited by - Hideo Fujii on 04/04/2017 10:17:16 AM |
|
|
Nackter Walter
7 Posts |
Posted - 04/05/2017 : 05:15:29 AM
|
Hi, I have send an e-mail. The only thing I do is to go the the sheet, open the worksheet script and click on run with the script from the forum in it. But there is no result and no error massage like it can be seen in the last picture I have posted. The worksheet itself is the active worksheet. Thank you for your time, I don't know what I'm doing wrong. |
|
|
|
Topic |
|