Cells cannot be copied from other worksheets

I’m using python 3 on windows, and I’m trying to create a new worksheet on exciting excel file and then copy rows from the first sheet to the new one depending on specific cells value, but when I’m trying it I get this Error:
“ValueError: Cells cannot be copied from other worksheets”.
Here is some of my code: (I’m importing load_workbook from openpyxl)

 def add_corrections(self):
    wb1 = load_workbook(self.path_to_save_use)
    wb1.create_sheet('תיקונים')
    columns = [('X', 'Y', 'Z', 'DZ')]
    for row in columns:
        wb1['תיקונים'].append(row)

    x = 0
    main_sheet = wb1['השוואת חתכים']
    for row in main_sheet.iter_rows():
        x = x + 1
        if x > 10:
            if row[9].value > self.limit:
                wb1['תיקונים'].append(row)
    wb1.save(self.path_to_save_use)

I have the x variable because I want to start looking from the 11th row

Answer

You are trying to append “row” object and not the value of that cell

wb1['תיקונים'].append(row)

“row” is the tuple of cells You have to convert that into list/tuple of values

x = 0
main_sheet = wb1['Sheet1']
for row in main_sheet.iter_rows():
    # HERE
    row_with_values = [cell.value for cell in row]
    # HERE
    x = x + 1
    if x > 10:
        if row[9].value > self.limit:
            wb1['תיקונים'].append(row_with_values)
    wb1['תיקונים'].append(row_with_values)

It works for my test scenario, I hope it works for you too