T O P I C R E V I E W |
sbaruah |
Posted - 11/16/2005 : 05:56:50 AM Origin Version (Select Help-->About Origin): 7 Operating System: win xp
Hi, I am just in the learner's state. Can you tell me the mistake in the following?
I want to delete such rows from a worksheet which contain the number 2 in a particular column (say C). Here it goes:
getnumber (total row number) rownum; // total row number in the main worksheet
work -d maindata; // duplicate the worksheet and call it maindata
window -a maindata; // set the window maindata as the active window
for(i2=1; i2<=rownum; i2=i2+1) { if(maindata_C[i2]==2) { work -s 1 $(i2) 5 $(i2); Menu -e 36442; //delete the whole row } } |
2 L A T E S T R E P L I E S (Newest First) |
sbaruah |
Posted - 11/16/2005 : 10:57:27 AM Hi, Thanks for your suggestion. It works nicely. Regards. |
Mike Buess |
Posted - 11/16/2005 : 08:08:59 AM Deleting a row renumbers all subsequent rows so it's better to start from the bottom and search up. This variation also uses the mark command to delete the row...
work -d maindata; get maindata_C -e rownum; // number of rows for(i2=rownum; i2>0; i2--) { if(maindata_C[i2]==2) mark -d maindata_C -b i2 -e i2; };
However, the following method will be much faster because it does not have to examine every row. It uses the list() function to find the next occurrence of the specified value.
work -d maindata; for(i2=1;i2>0;i2++) { ii=list(2,maindata_C); if(ii==0) break; mark -d maindata_C -b ii -e ii; };
Mike Buess Origin WebRing Member |