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
 Extracting 1st column from every sheet in workbook

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
Pavel.Bolshakov Posted - 10/04/2018 : 12:57:03 PM
OriginPro 2018

I need help to extract the first column in each worksheet in a workbook and put it into a new sheet, in sequential order.

For example:

I have 18 sheets,
the 1st column in sheet 1 to column 1 in new sheet
the 1st column in sheet 2 to column 2 in new sheet
.
.
.
the 1st column in sheet 18 to column 18 in new sheet.

In the end, I have a SINGLE new sheet with all 1st columns from all the other worksheet in sequential order.

I have made this manually:
colcopy irng:=[StressW80L40]Run163!col(A) orng:=[StressW80L40]Test!Col(B);
colcopy irng:=[StressW80L40]Run164!col(A) orng:=[StressW80L40]Test!Col(C);
colcopy irng:=[StressW80L40]Run165!col(A) orng:=[StressW80L40]Test!Col(D);
colcopy irng:=[StressW80L40]Run166!col(A) orng:=[StressW80L40]Test!Col(E);
colcopy irng:=[StressW80L40]Run167!col(A) orng:=[StressW80L40]Test!Col(F);
colcopy irng:=[StressW80L40]Run168!col(A) orng:=[StressW80L40]Test!Col(G);
colcopy irng:=[StressW80L40]Run169!col(A) orng:=[StressW80L40]Test!Col(H);
colcopy irng:=[StressW80L40]Run170!col(A) orng:=[StressW80L40]Test!Col(I);
colcopy irng:=[StressW80L40]Run171!col(A) orng:=[StressW80L40]Test!Col(J);
colcopy irng:=[StressW80L40]Run172!col(A) orng:=[StressW80L40]Test!Col(K);
colcopy irng:=[StressW80L40]Run173!col(A) orng:=[StressW80L40]Test!Col(L);
colcopy irng:=[StressW80L40]Run174!col(A) orng:=[StressW80L40]Test!Col(M);
colcopy irng:=[StressW80L40]Run175!col(A) orng:=[StressW80L40]Test!Col(N);
colcopy irng:=[StressW80L40]Run176!col(A) orng:=[StressW80L40]Test!Col(O);
colcopy irng:=[StressW80L40]Run177!col(A) orng:=[StressW80L40]Test!Col(P);
colcopy irng:=[StressW80L40]Run178!col(A) orng:=[StressW80L40]Test!Col(Q);
colcopy irng:=[StressW80L40]Run179!col(A) orng:=[StressW80L40]Test!Col(R);
colcopy irng:=[StressW80L40]Run180!col(A) orng:=[StressW80L40]Test!Col(S);

But it would take too long to have to retype the sheet name for every new file (Run###).

Thanks in advance for help.
2   L A T E S T    R E P L I E S    (Newest First)
Pavel.Bolshakov Posted - 10/05/2018 : 12:53:29 PM
quote:
Originally posted by Hideo Fujii

Hi Pavel.Bolshakov

To perform the script with a loop, you can use the column index instead of column name,
and the layer index instead of layer name. Can you try the following snippet?
wbn$="StressW80L40"; //Book name 
ns=page.nlayers;     //Original number of sheets
page.nlayers=ns+1;   //Update number of sheets
layer$(ns+1).name$="Test"; //New sheet name
for(ii=1; ii<=ns; ii++) {  //Loop over sheets
  colcopy irng:=[%(wbn$)]$(ii)!col(1) orng:=[%(wbn$)]%(layer$(ns+1).name$)!wcol(ii+1);
}
Did it work?

--Hideo Fujii
OriginLab



Thank you so much, it works!

Also, is there a way to do this without actually opening the Excel file in Origin? Simply have origin locate the file in some folder and extract the data from there?

All the best,

Pavel
Hideo Fujii Posted - 10/04/2018 : 5:03:32 PM
Hi Pavel.Bolshakov

To perform the script with a loop, you can use the column index instead of column name,
and the layer index instead of layer name. Can you try the following snippet?
wbn$="StressW80L40"; //Book name 
ns=page.nlayers;     //Original number of sheets
page.nlayers=ns+1;   //Update number of sheets
layer$(ns+1).name$="Test"; //New sheet name
for(ii=1; ii<=ns; ii++) {  //Loop over sheets
  colcopy irng:=[%(wbn$)]$(ii)!col(1) orng:=[%(wbn$)]%(layer$(ns+1).name$)!wcol(ii+1);
}
Did it work?

--Hideo Fujii
OriginLab

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