Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
zknauss
Posted - 07/25/2022 : 09:41:23 AM I am trying to run the following for/if statement
for (int i = 2; i <= wks.ncols; i++ ) { wcol(i)[1] = if([NCONT1PeakDat]"Frequency_N_CON_T1"!$(i)[10]==0,A,B); }
and am having two issues. first I cant seem to get the output letter into row 1 col "i" instead it seems to try to input the A or B column. Second, when I change the output to numeric values as below I always get the failed response of "2" and what I've determined is that it does not accept the values on the source worksheets and thus returns "2". The source worksheets that are compared here are located in separate folders of the project. I'd appreciate any help with getting this to work. Thanks!
for (int i = 2; i <= wks.ncols; i++ ) { wcol(i)[1] = if([NCONT1PeakDat]"Frequency_N_CON_T1"!$(i)[10]==0,1,2); }
ZTK
4 L A T E S T R E P L I E S (Newest First)
zknauss
Posted - 07/26/2022 : 09:34:52 AM That worked!! Thanks
ZTK
YimingChen
Posted - 07/25/2022 : 4:54:28 PM You are missing the dollar signs:
Posted - 07/25/2022 : 4:38:17 PM So that worked but the next few failed when I tried to run multiple if statements in the same line see below.
for (int i = 2; i <= wks.ncols; i++ ) { range aa = [NCONT1PeakDat]"Frequency_N_CON_T1"!$(i); range bb = [NCONT2PeakDat]"Frequency_N_CON_T2"!$(i); wcol(i)[2]$ = if(bb[10]>aa[15],"A",if(bb[10]<aa[14],"C",if(bb[10]==0,"D","B")))$; }
for (int i = 2; i <= wks.ncols; i++ ) { range bb = [NCONT2PeakDat]"Frequency_N_CON_T2"!$(i); range cc = [NCONT3PeakDat]"Frequency_N_CON_T3"!$(i); wcol(i)[3]$ = if(cc[10]>bb[15],"A",if(cc[10]<bb[14],"C",if(cc[10]==0,"D","B")))$; }
instead what I get is an output of the if statement at the end for example in row 2
"C",if(bb[10]==0,"D","B"
ZTK
YimingChen
Posted - 07/25/2022 : 11:12:27 AM You need to define a column range first. And you need dollar sign to assign text to a cell. Can you try the code below?
for (int i = 2; i <= wks.ncols; i++ )
{
range rr = [NCONT1PeakDat]"Frequency_N_CON_T1"!$(i);
wcol(i)[1]$ = if(rr[10]==0,"A","B")$;
}