+ Reply to Thread
Results 1 to 12 of 12

Vba code to vlookup the long list in excel

  1. #1
    Registered User
    Join Date
    02-11-2016
    Location
    dubai
    MS-Off Ver
    msoffice 2010
    Posts
    75

    Vba code to vlookup the long list in excel

    Dear Expert,

    I have a long list of data where i need VBA to help finding the related information.

    I have two worksheets (Sheet1 and Sheet2)

    On Sheet1
    I am keying the number on Cell A1 and keep on keying under A2...A3..A4....until many (it can cross 40000 cells)

    On Sheet2
    I have a data in F1 AND G1 so on... until last end of the rows..
    example:
    G1 will be - HANO201217526895
    F1 will be the short number of G1 which is brought with formula = Right(G1,6) (i.e. 526895)


    So on sheet1, result required to be placed on C1. By matching A1 of Sheet1 with G1 of sheet2
    Result : G1 of sheet2 to be avaialble in C1 of Sheet1

    Since it is a huge data for vlookup, need a code where it should not slown down the excel.

    Thanks

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Vba code to vlookup the long list in excel

    But isn't the C1 identical to the A1
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    02-11-2016
    Location
    dubai
    MS-Off Ver
    msoffice 2010
    Posts
    75

    Re: Vba code to vlookup the long list in excel

    Sheet1(A1) will be identical to Sheet2(F1), which will bring the result in Sheet1(C1) from Sheet2(G1)

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Vba code to vlookup the long list in excel

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  5. #5
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Vba code to vlookup the long list in excel

    Generally speaking, its practically impossible to write VBA code thats faster than built in functions. Many factors contribute to this, one of them being VBA is not threaded and built in functions are. Thats an over simplification of why, but is a practical explanation.

    There are things you can do to drastically speed up formulas. Sorting data is one easy to do thing that can help make lookups much faster. If what you are pulling over is numeric and not a string, a variation of SUMIF/SUMIFS would likely be much faster than a lookup. If you are referencing full columns in your VLOOKUP's, changing to reference only your data can drastically reduce calc time.

    A sample file would better help evaluate this.

    It is also a matter of relative time to complete the task. Slow down is a subjective concept. If your doing 40,000 look ups and it slows down for 3 seconds...thats actually reasonable. If it takes 15 mnutes that may not be. So exactly how slow is it now? Is it functional and calculating and it takes x minutes to finish or is the issue something else?

  6. #6
    Registered User
    Join Date
    02-11-2016
    Location
    dubai
    MS-Off Ver
    msoffice 2010
    Posts
    75

    Re: Vba code to vlookup the long list in excel

    pLEASE FIND ATTACHMENT. THIS IS JUST SAMPLE AS I HAVE HUGE MORE THAN 40000 numbers
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    02-11-2016
    Location
    dubai
    MS-Off Ver
    msoffice 2010
    Posts
    75

    Re: Vba code to vlookup the long list in excel

    Currently each cell is built with VLOOKUP formula. When i open the excel it takes a time to open and for search it takes a time.
    .
    Please support in giving the code, will check how much time it takes.
    .
    Thanks

  8. #8
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Vba code to vlookup the long list in excel

    Quote Originally Posted by anuwers View Post
    pLEASE FIND ATTACHMENT. THIS IS JUST SAMPLE AS I HAVE HUGE MORE THAN 40000 numbers
    Ok, was the sample created from scratch or was it created by sanitizing your actual file? If it was created from scratch it may not be possible to see underlying factors that impact your actual file.

    I also do not see your VLOOKUP in the sample, so I cannot speak to the possibility of improving the formula.

    Again, VBA is unlikely to be the solution for you if a vlookup does what you need and is subjectively slow to you.

  9. #9
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Vba code to vlookup the long list in excel

    Quote Originally Posted by anuwers View Post
    Currently each cell is built with VLOOKUP formula. When i open the excel it takes a time to open and for search it takes a time.
    .
    Please support in giving the code, will check how much time it takes.
    .
    Thanks
    Open and close time may have nothing to do with the formula other than if you have automatic calculation turned on. Try this, toggle to manual calc, save/close/reopen. If it opens immediately then its calc time and that may be something we can address with the formula if you provide an example based on your actual file, sanitized.

    If turning manual calc on doesnt improve the situation, then there is some aspect of your file causing it to be slow other than a formulas. We would have to inspect the file to find the culprit.

    Is your actual file just 1 sheet with 40k rows? if so how many columns?

    If its multiple sheets, how many? Do they also have alot of data?

    Whats the size of the file (how many KB, MB, etc)?

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Vba code to vlookup the long list in excel

    Hi anuwers I put an event in sheet1:

    Option Explicit

    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    02-11-2016
    Location
    dubai
    MS-Off Ver
    msoffice 2010
    Posts
    75

    Re: Vba code to vlookup the long list in excel

    thanks a lot it is working. But if i copy paste the list of numbers in A1 of sheet1, it is not working.

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Vba code to vlookup the long list in excel

    Replace event code with this:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] why won't vlookup work in a long list
    By KL in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 11:05 AM
  2. why won't vlookup work in a long list
    By KL in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 09-06-2005, 07:05 AM
  3. why won't vlookup work in a long list
    By KL in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 09-06-2005, 06:05 AM
  4. why won't vlookup work in a long list
    By pkeegs in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  5. [SOLVED] why won't vlookup work in a long list
    By pkeegs in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  6. why won't vlookup work in a long list
    By pkeegs in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. why won't vlookup work in a long list
    By pkeegs in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  8. [SOLVED] why won't vlookup work in a long list
    By pkeegs in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-02-2005, 10:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1