luiswiseman wrote:thanks for reply,
these are some of my variable value, (ElementA, 101,102,103,104,105, ElementB, 111, 122,123,124,126, ElementC, ....). What I'm going to do is I want to put the value from 101 till 105 into a particular cell and 111 till 126 into another cell. Logically, I can use the value 'ElementA' and 'ElementB' to separate them but how can I interpret them to if else statement.
I'm not sure that I follow you. Do you have these variables on a single record, so that each row contains ElementA, 101, 102, 103 (etc)? (Obviously 101, 102 etc must refer to the variable value, not the name, which might be something like V1, V2, V3 etc.)
If so you'd just add the variables together when doing the cellputn and use multiple statements.
CellPutN(V2+V3+V4+V5+V6, Elements that relate to ElementA);
CellPutN(V8+V9+V10+V11+V12, Elements that relate to ElementB);
and so on.
If these values are coming through in different rows, so that each row has (say)
ElementA, 101
ElementA,102
ElementA, 103
...
ElementB, 111
and so on,
you could use an If statement to work out the variables that the CellPutN is writing to but you'd
also need to aggregate the values by doing a CellGetN to get the current value, then writing the sum of that back to the cell. For instance:
dbl_CurrentVal = CellGetN(The elements that correspond to ElementA, B or whatever relates to that row);
CellPutN (dbl_CurrentVal+V2, The elements that correspond to ElementA, B or whatever relates to that row);
In this way you'd ultimately add up the 101, 102 etc values.