Author |
Topic |
|
mwambach
6 Posts |
Posted - 08/23/2016 : 1:12:52 PM
|
Hi there!
I wrote a simple script in Labtalk to delete rows with no value in Col(C). Unfortunately when I run it in the script window, only every other empty row is deleted. What's the error in the script? Cheers!
a=1; for (i=1;i<=1000;i++) { if (Col(C)[a]==0/0) { wks.deleteRows(a); } a=a++; }
|
|
snowli
USA
1391 Posts |
Posted - 08/23/2016 : 2:37:36 PM
|
Hello, this is because after you run wks.deleteRows(a) once, the row is already shifted upwards so the row indexing is updated.
E.g. if there are some missing values in row 10, 11, 12, 13. after deleting row 10, the old row 11, 12, 13 are row 10, 11, 12 now.
So instead of looping from 1 on, try loop of end of rows.
for (i=wks.nrows;i>=1;i--) { if (Col(C)[i]==0/0) { wks.deleteRows(i); } }
Thanks, Snow
|
|
|
mwambach
6 Posts |
Posted - 08/23/2016 : 2:51:44 PM
|
Hi Snow!
Thanks for your help! |
|
|
snowli
USA
1391 Posts |
Posted - 08/23/2016 : 4:09:51 PM
|
You are welcome.
Thanks, Snow |
|
|
|
Topic |
|
|
|