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
 variable number in worksheet and column name
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

antarsih

Ukraine
2 Posts

Posted - 09/25/2012 :  1:20:54 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello!
I have several worksheets with similar names, e.g. wks1, wks2, wks3.... Each worksheet includes several columns also with similar names, e.g. data1, data2, data3....

I am wondering if I can somehow replace number in the names with "i" and make a loop? I imagine it could be like this (but with correct syntax):

for (i = 1; i <= 5;i ++)
{
for (ii = 1; ii <= 10;ii ++)
{
wks10_results{i}=wks{i}_data{i}/wks{ii}_data{ii};
};};

I'll be grateful for help.

Kathy_Wang

China
159 Posts

Posted - 09/27/2012 :  01:04:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You could use the following syntax:

range ri = [Book1]wks$(i)!col(data$(i));


The range variable ri will be the datai column(i.e. column short name is datai) in worksheet wksi.

Hope this information helps!

Kathy
Originlab

Edited by - Kathy_Wang on 09/27/2012 01:04:48 AM
Go to Top of Page

antarsih

Ukraine
2 Posts

Posted - 09/27/2012 :  6:11:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, Kathy. This information is very helpful!

Edited by - antarsih on 09/27/2012 6:11:54 PM
Go to Top of Page

zevgdimi

4 Posts

Posted - 06/25/2015 :  4:21:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

I have the same problem but I do not understand the proposed solution. Could you please write the whole code?
To my specific problem: I have 16 columns which shall be named "Pix 1" to "Pix 16", so I would like to combine the string "Pix" with an integer increment.

Thanks
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