Reputation: 467
Is there a way to reference a cell A1 from Sheet2 to cell A1 of Sheet1?
='Sheet2'!A1
in the active worksheet?
Apparently, the following doesn't work
wb = load_workbook(test.xlsx)
ws = wb['Sheet1']
ws['A1'] = "='Sheet2'!A1)"
Upvotes: 0
Views: 1764
Reputation: 1623
Did you save the workbook using wb.save? and Also remove the ) in the formula.
use this code below for achieving the functionality.
import openpyxl
wb=openpyxl.load_workbook('test.xlsx')
ws = wb['Sheet1']
ws['A1'] = "='Sheet2'!A1"
wb.save('test.xlsx')
Upvotes: 1