I'm trying to write a formula into a cell and write for the entire column. However, for each cell in the column, it reads =(E2-F2)/C2
. For each cell on the same column how do I get it so reads (E3-F3)/C3
and so on?
import openpyxl
wb = openpyxl.load_workbook('yes.xlsx')
Sheet = wb.get_sheet_by_name('Sheet1')
n = '=(E2-F2)/C2'
for cellObj in list(Sheet.columns)[6]:
cellObj.value = n
wb.save("row_creation_loop.xlsx")
From my comment, here is the
for
-loop code in full:Hope this helps.
you have to add +1 at the
r(row, row, row)
.