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
 Add cell value of one wks to wb in subsequent rows

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
nexusnex Posted - 10/30/2019 : 3:34:06 PM
Hello guys,

I have been lurking through the forum but couldn't find a solution so I had to create this post, sorry for this. Also, I am not good at Labtalk so I might not express myself correctly or use the right words, so please bear with me.

My situation and problem and what I want to do:
I have a ton of worksheets in one workbook that are ordered in number. These worksheets have one thing in common: 5 columns and 20.000 rows.
What I want to do is:
1. Create a separate workbook
2. Select cells(17432,5) of N worksheets and add their value to the new workbook at cell(N,1)

For example:
workbook cell(1,1) = worksheet number 1 cell(17432,5)
workbook cell(2,1) = worksheet number 2 cell(17432,5)
workbook cell(3,1) = worksheet number 3 cell(17432,5)
etc.

So I have the data value of each worksheet ordered in the new workbook. My problem is how can I create a new workbook and loop (that means the page needs to be active right??) through the worksheets of another workbook and add their data value of each cell(17532,5) to the new workbook (which is then inactive??)

I am really frustrated because I really dont know how I can do this... hope you can help me and thank you so much in advance.

Best regards!
4   L A T E S T    R E P L I E S    (Newest First)
couturier Posted - 11/01/2019 : 3:59:42 PM
string strBk$=%H; // Assuming active workbook has all data, stores book name into string variable
NewBook;
range wkb=[%(strBk$)];
range rC1=1, rC2=2; // 1st and 2nd col of newly created book
for (int ii=1; ii<=wkb.nlayers; ii++) { // loop through worksheets
range rcol=[%(strBk$)]$(ii)!5; // 5th col on wks number ii
rC1[ii]=rcol[17432];
rC2[ii]=rcol[12455];
}
nexusnex Posted - 11/01/2019 : 07:01:11 AM
quote:
Originally posted by couturier

Hi,

open Script Window (Menu Window/Script Window) and paste the following script:
range wkb=[%H]; // active workbook, in which you have all your data
dataset ds; // temporary dataset
for (int ii=1; ii<=wkb.nlayers; ii++) { // loop through worksheets
range rcol=[%H]$(ii)!5; // 5th col on wks number ii
ds[ii]=rcol[17432]; // assign cell 17432 to row ii of temp dataset
}
newbook; // new workbook
range rcol=1; // 1st col in new workbook
rcol=ds; // put temp dataset into col


Select all the lines in Script Window and press Enter


Hi,

I have another question. If I want to add something to the first example and want to do something like this
workbook cell(1,1) = worksheet number 1 cell(17432,5)
workbook cell(1,2) = worksheet number 1 cell(12455,5)

workbook cell(2,1) = worksheet number 2 cell(17432,5)
workbook cell(2,2) = worksheet number 2 cell(12455,5)

that means I want to add the data value from another cell of the worksheet to the second column, how would I go about this using your script?
Something like this?

range wkb=[%H]; // active workbook, in which you have all your data
dataset ds; // temporary dataset
for (int ii=1; ii<=wkb.nlayers; ii++) { // loop through worksheets
range rcol=[%H]$(ii)!5; // 5th col on wks number ii
ds[ii]=rcol[17432]; // assign cell 17432 to row ii of temp dataset
ds[ii]=rcol[12455];
}
newbook; // new workbook
range rcol=1; // 2nd col in new workbook
rcol=ds; // put temp dataset into col
range rcol=2;
nexusnex Posted - 10/31/2019 : 08:04:39 AM
That works wonderfully! Thank you so so much!
couturier Posted - 10/31/2019 : 04:07:25 AM
Hi,

open Script Window (Menu Window/Script Window) and paste the following script:
range wkb=[%H]; // active workbook, in which you have all your data
dataset ds; // temporary dataset
for (int ii=1; ii<=wkb.nlayers; ii++) { // loop through worksheets
range rcol=[%H]$(ii)!5; // 5th col on wks number ii
ds[ii]=rcol[17432]; // assign cell 17432 to row ii of temp dataset
}
newbook; // new workbook
range rcol=1; // 1st col in new workbook
rcol=ds; // put temp dataset into col


Select all the lines in Script Window and press Enter

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