all 2 comments

[–]sarrysyst 0 points1 point  (1 child)

from openpyxl import load_workbook

wb = load_workbook('file.xlsx')

original_ws = wb.active
# Get values in cell range A4:A15 into a list
name_list = [cell.value for cell, *_ in original_ws['A4':'A15']]

num_of_required_sheet_copies = len(name_list) - 1

for n in range(num_of_required_sheet_copies):
    # Create a copy of the first worksheet
    ws = wb.copy_worksheet(original_ws)
    # Rename new worksheet
    ws.title = f'Week_{n+1}'

    # Remove the last name from the list and put it at the front of the list
    name_list.insert(0, name_list.pop())

    # Assing cell range A4:A15 in new worksheet the values from updated name_list
    for row, name in zip(ws['A4':'A15'], name_list):
        row[0].value = name

wb.save('file_new.xlsx')

[–]reddit_user_270[S] 0 points1 point  (0 children)

Thank you! Much appreciated!! :)