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
 Using range as string to acces different sheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

mrandersb

25 Posts

Posted - 06/23/2010 :  11:22:23 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hey I have one book with one sheet in it. in that sheet there is an column with different ID numbers in them. I try to use the "set values" on another column, and would like to use the given ID to acces another sheet with that ID as a name.

My try was something like this:

range cc = [Book2]Sheet1!Col(D1);

string ttt$ = "cc";

range test = [ttt$]ttt$!;
NumberOfRows = test.nRows/test.nCols;

double A = 0;

for(ii = 1; ii <= NumberOfRows; ii++)
{
A = A + ID23017_A[ii];
}

A = A/NumberOfRows;








If i change the line

string ttt$ = "cc";

with

string ttt$ = "ID23017";

it works (ID23017 is one of the correct IDs)

Laurie

USA
404 Posts

Posted - 06/23/2010 :  12:31:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
string ttt$ = "cc";

After running the above assignment statement, if you check the value of ttt$ you'd see it holds the string "cc".

If you wanted it to return "[Book2]Sheet1!Col(D1)" then you'd use the following:

string ttt$ = %(cc);

but I think when you say the column has an ID that you mean the ID is the Long Name?

so what you really want is the following:

range cc = [Book2]Sheet1!Col(D1);
string ttt$ = cc[L]$;

Also when you use the ID23017_A notation, you could replace that with range notation too. Create a range variable that is the A column in the ID23017 sheet and then use that. For example:

range rr = [SomeBook]ID23017!col(A);
A = A + rr[ii];

By the way, replace "A = A + rr[ii];" with "A+=rr[ii];". This shorthand notation will also result in a speedier calculation.

OriginLab Technical Support
Go to Top of Page

mrandersb

25 Posts

Posted - 06/24/2010 :  02:36:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I still get an expression error, with both methods. How do i check what is in the ttt string. I'm programming in the Set values - Before formula scripts window.

ps. Are there a better place to be programming these things?
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