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
 Extracting 1st column from every sheet in workbook
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Pavel.Bolshakov

USA
2 Posts

Posted - 10/04/2018 :  12:57:03 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

Hideo Fujii

USA
1582 Posts

Posted - 10/04/2018 :  5:03:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - Hideo Fujii on 10/04/2018 5:07:42 PM
Go to Top of Page

Pavel.Bolshakov

USA
2 Posts

Posted - 10/05/2018 :  12:53:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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