import openpyxl as py
wb = py.load_workbook('Book1.xlsx')
ws = wb.active
aaa = []
for row in ws.iter_rows(min_row=1):
values = []
for c in row:
values.append(c.value)
aaa.append(tuple(values))
code = ['100','102']
bbb = []
for ccc in aaa:
if ccc[0] in code:
bbb.append(ccc)
wbwb = py.load_workbook("結果.xlsx")
wsws = wbwb.active
maxrow = wsws.max_row
maxcol = wsws.max_column
for ddd in bbb: #ここを追加
if ddd[2] in '本店':
if ddd[0] in '100':
wsws.cell(row=2,col=3).value = ddd[3] #試しに1セル転記できるか
wbwb.save("結果.xlsx")
>meg_ 様
御返信ありがとうございます。
IndexError Traceback (most recent call last)
<ipython-input-15-ffb0b9744663> in <module>()
29 maxcol = wsws.max_column
30
---> 31 if bbb[3] in '本店':
32 if bbb[0] in 100:
33 wsws.cell(row=2,min_col=3).value = bbb
IndexError: list index out of range
というエラーが表示されてどうしたらよいか行き詰まっています