I'm a super beginner at Python.
Load the prepared Excel using openpyxl and
You would like to enter any number next to a cell containing a specific character.
In the image below, the target is indicated, but
if a specific string is included.
I would like to enter any number in the cell next to me.
If you have any ideas to realize them, please let me know.
python openpyxl
from openpyxl import load_workbook
wb=load_workbook("test.xlsx")
ws = wb.active
target_col="A"
next_col="B"
target_string = "target"
for row in range(2,ws.max_row+1):
if target_string instr(ws[f"{target_col}{row}"].value):
ws [f"{next_col}{row}"] = 1
wb.save("test_copy.xlsx")
© 2024 OneMinuteCode. All rights reserved.