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
 script to copy and paste from subset of 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
wmfry Posted - 01/03/2011 : 7:51:18 PM
Hi
I'd appreciate some help in writing a script. Consider two worksheets, the second contains data for only a subset of rows of the first. How do I make origin paste the data from the second worksheet into the corresponding rows of the first worksheet?

I hope the following example using a registration list and exam for a course will help:


Consider the Registration sheet for september
A(x) b(y)
Name student #
Anne 101
Bill 128
Charlie 178
Dawn 155
evan 103
Frank 190


now imagine charlie drops the course before the midterm. the data set with the midterm marks look like this.

A(x) b(y) c(y)
Name student # midterm mark (/50)
Anne 101 33
Bill 128 20
Dawn 155 40
evan 103 35
Frank 190 38

I'd like to paste the marks (column C) from the above spreadsheet into the first, but it is missing the row for charlie, and manual intervention is required to correctly associate each student with their midterm mark.

How do i make origin pick each student's midterm data from column c(midterm mark) of the second worksheet and correctly paste it into the first worksheet? the end result will have an empty cell for charlie's midterm.

I apologize if my explaination is not clear.

thanks
Mark Fry






Origin Ver. and Service Release 8e
Operating System: XP Pro
1   L A T E S T    R E P L I E S    (Newest First)
Sam Fang Posted - 01/04/2011 : 03:26:04 AM
In Origin8, you can use X-Function vfind to find the row number in the first worksheet corresponding to cells of the second worksheet. For your example, suppose that the first worksheet is in Book1, second is in Book2, script can be as follows.

range r1=[Book1]1!;
r1.ncols=r1.ncols+1;
range r2b=[Book2]1!col(B);
nr=r2b.GetSize();
range r1b=[Book1]1!col(B);
range r1c=[Book1]1!col(3);
range r2c=[Book2]1!col(C);

for( i=1; i<= nr; i++)
{
  vfind ix:=r1b value:=r2b[i] ox:=vr;
  ir=vr[1];
  r1c[ir]=r2c[i];
}


Sam
OriginLab Technical Services

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