+ Reply to Thread
Results 1 to 5 of 5

V-lookup not giving correct results through VBA

  1. #1
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    V-lookup not giving correct results through VBA

    Hi,

    In my attached file there are two months of data: Previous Month and Current Month.
    In current Report sheet- I want COl. O be updated with a lookup value from Col. H in Previous report sheet. Any cell that comes as blank should be updated as Added.
    When I run the below mentioned code, my results for Small Switches are coming as 119 whereas it should be 104. Please assist. Below is my code and attached is the dummy file. Please assist at the earliest. Thank you.

    Please Login or Register  to view this content.
    Please note- I tried changing the lastrow3 and it worked but then in this case, it takes time to run. Any help?

    I changed the last row 3 as:

    lastRow3 = sht4.range("a1").End(xlDown).Row
    Attached Files Attached Files
    Last edited by ruchikasharma9727; 07-01-2020 at 08:20 AM. Reason: Changed the Lastrow3

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: V-lookup not giving correct results through VBA

    no attachment, in order to check you code and the value of the variables
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    06-23-2020
    Location
    India
    MS-Off Ver
    2010
    Posts
    25

    Re: V-lookup not giving correct results through VBA

    Just added it.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: V-lookup not giving correct results through VBA

    First I assume i need to add 2 worksheets in order for the code to even run?

    Where is 109? You need to explain exactly where the information is not as expected, what you think it should be and why?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: V-lookup not giving correct results through VBA

    I did the formula manually and I can see there are 104 records that are both #N/A and "Small Switch".

    I do not get 109 after running your code, I get 104 as expected

+ 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] Index/match giving correct results, wrong results & #N/A results...sometimes
    By mrteater in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-27-2019, 10:41 AM
  2. [SOLVED] lookup formula not giving expected results when criteria entered
    By JEAN1972 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-31-2019, 06:10 AM
  3. Graph not giving correct results. Y values not applying?
    By HarvardMajesty in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-12-2016, 09:37 AM
  4. [SOLVED] Correct Formula not giving results
    By NJ007 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-25-2014, 09:06 PM
  5. Issue with Lookup giving multiple results
    By Acollias in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-29-2013, 07:52 AM
  6. Lookup or match function with multiple criteria giving different results
    By Mian USman in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-24-2013, 09:15 AM
  7. How do I get correct results when LOOKUP with calculated numbers
    By onthemountain in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-19-2006, 08:20 PM

Tags for this Thread

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