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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Using range as string to acces different sheet

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
mrandersb Posted - 06/23/2010 : 11:22:23 AM
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)
2   L A T E S T    R E P L I E S    (Newest First)
mrandersb Posted - 06/24/2010 : 02:36:36 AM
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?
Laurie Posted - 06/23/2010 : 12:31:14 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000