I'm not sure what type of calculation you are performing here
Num(Substr(Char(Column(dt1, "Median")[dt1 << get rows where(:Tests == element)] - Column(dt2, element)), 1, digt + 1)) + Column(dt2, element)
but something like this might help you
Names Default To Here(1);
dt1 = Open("$DOWNLOADS/dt_ref.jmp");
dt2 = Open("$DOWNLOADS/Data table.jmp");
digt = 5;
itsel1 = {"Currents A", "Currents A2", "Currents A3", "Currents A4", "Currents A5"}; //List of columns to align.
dt2_colnames = dt2 << Get Column Names("String");
//// Loop to calculate the delta between the dt1 and dt2 and the add the delta to the column of dt2 from the itsel1 list
For Each({colname}, itsel1,
dt2_col_idx = Contains(dt2_colnames, colname);
If(dt2_col_idx == 0,
Print("Skipped column: " || colname);
continue(); // skip this column
);
dt1_row_idx = Loc(dt1[0, "Tests"], colname);
If(N Items(dt1_row_idx) == 0,
Print("Skipped row: " || colname);
continue();
,
dt1_row_idx = dt1_row_idx[1];
);
dt2[0, dt2_col_idx] = dt2[0, dt2_col_idx] - dt1[dt1_row_idx, "Median"];
);
-Jarmo