Python Forum
How to apply VLookup formula
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to apply VLookup formula
#1
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:


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
Reply
#2
Please be more precise. Please give the complete error message and on which line in the part of the code you show us.
Reply
#3
There is not enough information here to help you.
You need to post a sample of States.xlsx along with your circular error in its entirety.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Vlookup function in Pyhton antozas 1 1,786 Oct-02-2023, 04:16 AM
Last Post: vikraman
  How to apply function lower() to the list? Toltimtixma 2 1,879 Feb-10-2023, 05:15 PM
Last Post: Toltimtixma
  "Vlookup" in pandas dataframe doug2019 3 3,911 May-09-2022, 01:35 PM
Last Post: snippsat
  Python VLookup? Lookup Table? Nu2Python 3 4,767 Oct-25-2021, 08:47 PM
Last Post: Nu2Python
  Python “Formula” Package: How do I parse Excel formula with a range of cells? JaneTan 1 4,463 Jul-12-2021, 11:09 AM
Last Post: jefsummers
  IF statement to apply at each date illmattic 2 3,825 Apr-08-2021, 12:31 PM
Last Post: illmattic
  Function won't apply dynamically in timeseries illmattic 1 2,649 Jan-08-2021, 03:15 PM
Last Post: stullis
  trying to do a vlookup in pandas eeps24 1 2,991 May-22-2020, 02:10 PM
Last Post: eeps24
  Issue in .apply function fullstop 0 2,325 Dec-17-2019, 01:29 PM
Last Post: fullstop
  Apply a function with pandas Jompie96 2 3,450 Jun-13-2019, 07:04 PM
Last Post: Jompie96

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.