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
 Copying column from different worksheets to one
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ox1986

United Kingdom
1 Posts

Posted - 09/09/2014 :  11:46:43 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I would be grateful for some help. Im new to Labtalk and I am trying to copy many columns (each column is from a different worksheet in a different workbook) and put them into a new workbook so that they all sit next to each other

Is there a way to do this through looping? I've not been able to work it out thus far

Many thanks for any suggestions

H

greg

USA
1378 Posts

Posted - 09/09/2014 :  2:35:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You don't specify what column to copy...

Here is an example that copies all column 3 to a new worksheet:

colforcopy = 3;
newbook name:=Collected;
tcol = 1;
doc -e W
{
if(page.longname$ != "Collected")
{
loop(ii,1,page.nlayers)
{
page.active = ii;
wrcopy
ow:=[Collected]Sheet1!
c1:=colforcopy
c2:=colforcopy
dc1:=tcol
label:=1
format:=1;
tcol++;
}
}
}

Go to Top of Page

qavo08

USA
2 Posts

Posted - 07/16/2017 :  01:03:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

I want to copy a column named "Mean" in each workbook to a new workbook. Each workbook has one sheet. I tried to use the code below, but it always copies all columns in every workbook to the new workbook. I tried to add an else, break; but it's still the same. Any suggestion would be appreciated.

Here is the code I used:

newbook name:=Collected1;
tcol = 1;
doc -e W
{
if(page.longname$ != "Collected1")
{
loop(ii,1,page.nlayers)
{
page.active = ii;
loop(iii,1,wks.nCols)
{
range rr = wks.col$(iii)
if (rr.name$ = "Mean") 
{
colforcopy = iii;
wrcopy
ow:=[Collected1]Sheet1!
c1:=colforcopy
c2:=colforcopy
dc1:=tcol
label:=1
format:=1;
tcol++;
}
}
}
}
}


Edited by - qavo08 on 07/16/2017 01:26:58 AM
Go to Top of Page

yuki_wu

896 Posts

Posted - 07/16/2017 :  11:25:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Please modify your code as follows:

// Add the missing semicolon, 
// and declare a range for a column by its index directly 
// since wks.col is used to access the column attributes
range rr = $(iii); 
// Use double equal-sign 
// while single equal-sign is used to assign value,  
// rr.name$ means the short name 
// while rr.lname$ means the long name
if (rr.lname$ == "Mean")


Hope it can be some help.

Regards,
Yuki
OriginLab

Edited by - yuki_wu on 07/16/2017 11:27:03 PM
Go to Top of Page

qavo08

USA
2 Posts

Posted - 07/17/2017 :  5:55:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It works perfectly. Thank you Yuki.
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