Jan-12-2020, 03:30 PM
Hello,
I am learning to apply VLookup in Python and in this short example trying to pull full names of the states when I pass the short names. For example SC should return South Carolina and TX should become Texas. States sheet has short names and Full Name sheet is where lookup value is coming from. According to my research I am using the correct formula syntax but after this program runs it keeps saying circular error and there is something wrong with this formula. Can someone please provide me some guidance.
Here is the code:
I am learning to apply VLookup in Python and in this short example trying to pull full names of the states when I pass the short names. For example SC should return South Carolina and TX should become Texas. States sheet has short names and Full Name sheet is where lookup value is coming from. According to my research I am using the correct formula syntax but after this program runs it keeps saying circular error and there is something wrong with this formula. Can someone please provide me some guidance.
Here is the code:
from os.path import join, dirname, abspath import openpyxl as op # open the destination file for writing fpath = join(dirname(dirname(abspath(__file__))), 'C:\\', 'States.xlsx') dWB = op.load_workbook(fpath) ST = dWB['States'] for row in ST['A2:A3']: for cell in row: cell.value = "=VLOOKUP(A{0}, 'Full Name'!A2:B4, 2, FALSE)".format(cell.row) dWB.save(fpath)Thanks