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
 Performing operations on 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

JonasKlim

Lithuania
36 Posts

Posted - 10/30/2017 :  06:38:50 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
How to write a loop to perform operations on all sheets in a workbook except sheet named "Sheet1"?

yuki_wu

896 Posts

Posted - 10/30/2017 :  06:58:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I think you may want something like this.

doc -e LW  //Loop over all worksheet in the current workbook only
{
	string str wks.Name$;
        if(str != “Sheet1”)
        {
 	 …
        }
}

Hope it helps.

Regards,
Yuki
OriginLab
Go to Top of Page

JonasKlim

Lithuania
36 Posts

Posted - 10/30/2017 :  08:49:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Yuki,

int rot=0;
doc -e LW //Loop over all worksheet in the current workbook only;
{
string str$= wks.Name$;
rot=rot+1;
if (str$ != "Sheet1") {rot= ; str$=;}

};
has worked.
Thanks.
Jonas

quote:
Originally posted by yuki_wu

Hi,

I think you may want something like this.

doc -e LW  //Loop over all worksheet in the current workbook only
{
	string str wks.Name$;
        if(str != “Sheet1”)
        {
 	 …
        }
}

Hope it helps.

Regards,
Yuki
OriginLab


Edited by - JonasKlim on 10/30/2017 09:40:57 AM
Go to Top of Page

JonasKlim

Lithuania
36 Posts

Posted - 10/31/2017 :  08:26:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
I want to write name of the sheet to a cell. What shall be corrected in the script below?
//;
string str$= wks.Name$;
str$=;
range aa= Sheet1!Col(C)[1];
aa=str$;
//;
("str$=" prints sheet name, but sheet name is not written in Col(C)[1].)
Please advise.

Jonas
Go to Top of Page

yuki_wu

896 Posts

Posted - 10/31/2017 :  11:30:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jonas,
string str$ = wks.Name$;
range aa = col(A);
aa[1]$ = str$;

http://www.originlab.com/doc/LabTalk/Tutorials/Tutorial-Range-Notation

Hope it helps.

Regards,
Yuki
OriginLab
Go to Top of Page

JonasKlim

Lithuania
36 Posts

Posted - 11/01/2017 :  10:21:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Yuki,

Thank you, this way it worked.
Why it did not work when I have defined range range " aa= Sheet1!Col(C)[1]; ", pointing to specific cell?
Regards,

Jonas

quote:
Originally posted by yuki_wu

Hi Jonas,
string str$ = wks.Name$;
range aa = col(A);
aa[1]$ = str$;

http://www.originlab.com/doc/LabTalk/Tutorials/Tutorial-Range-Notation

Hope it helps.

Regards,
Yuki
OriginLab


Go to Top of Page

yuki_wu

896 Posts

Posted - 11/02/2017 :  01:55:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jonas,

Range is a data type that allows you to access columns, worksheet, matrix or loose dataset. It is just like a general vector, so you can’t assign a string variable to a vector. While aa[1] is considered as an element of the vector, so it works.

Regards,
Yuki
OriginLab
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