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 of every column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Nackter Walter

7 Posts

Posted - 03/31/2017 :  09:49:42 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Nackter Walter

7 Posts

Posted - 04/03/2017 :  11:41:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for your answer but this code don't work too.
The result can be seen in the following:
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 04/03/2017 :  12:44:12 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Nackter Walter

7 Posts

Posted - 04/04/2017 :  03:57:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have also tried this yesterday, but this isn't working too.
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 04/04/2017 :  10:16:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Nackter Walter

7 Posts

Posted - 04/05/2017 :  05:15:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
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