Hi gulitog1A
The following sample may serve your purpose: ////////////////////////////////////
function double difv(double v1, double v2) {
return abs(v1-v2);
}
target=1;
minv=1e307;
Loop(ii,1,wks.maxRows) {
d=difv(col(1)[ii], target);
if(d<minv) { minv=d; mini=ii; }
}
//// Output results /////
worksheet -a 3;
nc=wks.ncols;
wcol(nc-2)[C]$=Index; wcol(nc-2)[1]=mini;
wcol(nc-1)[C]$=X; wcol(nc-1)[1]=col(1)[$(mini)];
wcol(nc)[C]$=Y; wcol(nc)[1]=col(2)[$(mini)];
////////////////////////////////////
Hope this helps.
--Hideo Fujii
OriginLab