Subscribe Bookmark RSS Feed

Select a group of cells in a column

SamH

Contributor

Joined:

Mar 3, 2017

Hi, I have table with thousands of rows. I need to be able to select a group of cells in one column, so I could copy it into another table. for example for Column: "Test3 (VOLTS)" only I need to copy cells highlighted in yellow from row 4 thru row 18 using JSL code.

Thanks

JMP.jpg

 

11 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Here is a simple example  of one way to do it

Names Default To Here( 1 );

dt = Open( "$sample_data\big class.jmp" );

// copy the names from row 2-6
NameCpy = dt:name[Index( 2, 6 )];

dt2 = New Table( "copied", New Column( "new name", character ) );
dt2 << add rows( 5 );

// copy to new table
For( i = 1, i <= 5, i++,
	dt2:new name[i] = NameCpy[i]
);

If you actually have physical rows that are selected, you can easily get their row number with a:

 

     dt<<get selected rows

Jim
SamH

Contributor

Joined:

Mar 3, 2017

Thanks that should work, I tried with Big class file.

Much appreciated

Sam.

SamH

Contributor

Joined:

Mar 3, 2017

Hi Jim, how can I select a range of cells withing one column?

for example if I want to select cell 2 thourgh cell 19 within the same column.

Because I want to use this selection to be able to do "Select Matching Cells" within the same column.

 

Thanks

Sam

txnelson

Super User

Joined:

Jun 22, 2012

Here is the example for "Select Matching Cells" taken from

     Help==>Scripting Index

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Select Rows( [1, 2, 3, 4] );
dt << Go To( :Height );
Wait( 2 );
dt << Select Matching Cells();
Jim
SamH

Contributor

Joined:

Mar 3, 2017

Hi Jim, instead of hand picking what cells to select, can I pick a range let's say 2-19?

Thanks

 

SamH

Contributor

Joined:

Mar 3, 2017

or row 12 thru 40 in column "height"

SamH

Contributor

Joined:

Mar 3, 2017

col.jpg

SamH

Contributor

Joined:

Mar 3, 2017

Jim, I am trying to automate this process, because the files I am dealing with could have 1k-2k rows. if I have to specify every row, my code will be so many pages.
SamH

Contributor

Joined:

Mar 3, 2017

Jim, I figured it out, here is the code it works.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
L = N Rows( dt ); // number of rows
For( i = 3, i <= L, i++,
dt << Select Rows( i, L );
dt << Go To( :Height );
);
Wait( 2 );
dt << Select Matching Cells();