You may copy and paste following codes to "Before formula scripts" to set values. Please note that if p and r are characters, please add "" in the scripts. Here we assume p and r are characters.
int i;
for (i=1;i<=wks.maxrows;i++)
{
if( Col(A)[$(i)] == "p")
{
a=Col(CenterX)[$(i)];
b=Col(CenterY)[$(i)];
Col(SpotAngleSan)[$(i)] =atan(a/b);
}
else
{
a= Col(CenterY)[$(i)];
b= Col(CenterX)[$(i)];
Col(SpotAngleSan)[$(i)] =atan(a/b);
}
}
For the flag column has only two values p or s, there is another way to solve the problem. You can past the following code in the Column formula (which is in the middle panel of Set Values dialog.):
(col(A)=="p") ? atan(col(CenterX)/col(CenterY)) : atan(col(CenterY)/col(CenterX))
For the computation speed may be slower when you use loop in "Before formula scripts", we recommend you to use the second way to Set Values.
Best regards,
Vincent Liu
OriginLab Technical Services