Imagine a very simple problem:
- Column A has a list of values (say A1: 1, A2: 2, A3: 3)
- Cell C1 is a simple formula (say B1^2)
I wat to iterate the values in A, giving them to B1 each at a time, and save the results in a new list.
for idx in range(number_inputs):
input_cell = f'A{(1+idx)}'
target_cell = f'D{(1+idx)}'
sheet['B1'] = sheet[input_cell].value
sheet[target_cell] = sheet['C1'].value
The problem is that I cannot copy the value of C1, only the formula. The solution to this problem seems to be to load the workbook with the option data_only=True
, but this does not work for me, since I need the formula in B1.
I was trying inelegant and desperate solutions, like copying my sheet to a new one... but this also copies the formulas.
Frankly, this seems like a surprisingly hard thing to do given how basic the goal is. Is there anything I am missing, or is this impossible to achieve?