Posted on 2011-04-26
Last Modified: 2012-05-11

I have two VBA Editor Vlookups (attached)

In excel, the first lookup returns formulae:
=VLOOKUP(L2,'[Prime Dividends Checker.xls]PAID DIVS'!$D:$D,1,0)

The second returns:
=VLOOKUP(W2,'[Prime Dividends Checker.xls]PAID DIVS'!'E4',1,0)

The key difference in the returned formulae is the second does not search the column

I recorded the forst vlookup as a macro and then copy/pasted it for the second, adjusting columns

Why is there is a diffirence in result when the first formulae is the same in the editor?


.Range("AC2").Formula = "=VLOOKUP(RC[-17],'[Prime Dividends Checker.xls]PAID DIVS'!C4,1,0)"
    .Range("AD2").Formula = "=VLOOKUP(RC[-7],'[Prime Dividends Checker.xls]PAID DIVS'!E4,1,0)"

Open in new window

Question by:Seamus2626
    LVL 85

    Accepted Solution

    C4 in the first stands for Column 4 as you are using R1C1 format. E4 can only be a cell reference. If you meant column E, you should use C5.
    You should also use FormulaR1C1 rather than Formula.
    LVL 31

    Assisted Solution

    by:Rob Henson
    The first formula is seeing the C4 as column 4 whereas the second is seeing the E4 as a cell reference.

    With more info, might be able to correct it.

    Rob H
    LVL 50

    Expert Comment

    in this formula

    =VLOOKUP(L2,'[Prime Dividends Checker.xls]PAID DIVS'!$D:$D,1,0)

    the lookup range is the whole column D

    In the second formula,

    =VLOOKUP(W2,'[Prime Dividends Checker.xls]PAID DIVS'!'E4',1,0)

    the lookup range consists of just one cell, E4. So unless the search term is present in that cell, the Vlookup will return an error.

    The second formula in your code snippet also refers to just one cell as the lookup range. That won't work well. You need a range with more than one row for a meaningful result.

    cheers, teylyn

    Author Closing Comment

    Thanks Fellas,

    Understand now.


    Author Comment

    Thank you too Teylyn, just seen your response


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
    Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
    The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
    This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now