Python 3.7.1
I have an excel which looks like something like this
With my script I would like to find the row where is "222" located and update this line. I write a script which can find that kind of row but only that case if the cell contains text.
The script:
from openpyxl import load_workbook
issue = "222"
path = "\\.xlsx"
wb = load_workbook(path)
ws = wb.worksheets[0]
for row in ws.iter_rows():
for cell in row:
if cell.value == issue:
print (cell.coordinate)
Outcome:
The problem in my case that the cells are only contains numbers. I already searched on the web but didn't find any solution why the script don't find number in my xls.
Thank you in advance!
Problem looks to be line 2: issue = "222"
. You defined issue as a string containing the numbers 222. Instead just change that to issue = 222
and it should work as expected.