VLOOKUP is returning incorrect column values

Hi folks,


I'm having some issues with a simple VLOOKUP formula. There's nothing I can see that I'm doing wrong but my VLOOKUP function always seems to return the wrong column value, and return incoherent errors such as 'argument 3 must be greater than or equal to 1' even though the cell value is 2.


The table is for an energy use calculator I'm building, and I'm want to enter the model number and have the corresponding cells autofill. But when I enter my VLOOKUP formula to return heating power input, for example, the cell returns the model number. See pic.


User uploaded file


As you can see, the cooling power input cell is similarly showing the model number. However, this is only because the cooling power input shows a value greater than 1. If it shows its true value of 0.96, it instead gives me an error saying the cell value needs to be greater than 1. So depending on the cell value, it either returns an error, or the model number. See pics again.

User uploaded file


User uploaded file


I can also enter the same formula into different cells, but referencing different columns, and they still return the same value from an entirely different column!



User uploaded file

Also, when it pulls the wrong cell info into the table, it will do it with text (such as in the model number it returns in place of the CPI) but if you actually want it to return a text value from the chosen column in argument 3, it chooses the right cell, but says it can't display a text value!


I've only selected a small range here as a demo - the actual range is close to 13k rows, but it does the same thing regardless.


I'm going absolutely stir crazy here - there's no rhyme or reason for it as far as I can see. I'm fairly new to using the vlookup function but as far as I can see I'm doing it all right. Can anyone help me with this? I would be so grateful.

MacBook Air, iOS 6.1.4

Posted on Jul 16, 2013 11:52 PM

Reply
3 replies

Jul 17, 2013 1:06 AM in response to Neewok

Hi Neework,


The syntax for VLOOKUP can be found in the Function Browser (Click the ƒx button in the toolbar, and choose Show Function Browser). Here's what it says:


VLOOKUP


The VLOOKUP function returns a value from a range of columns by using the left column of values to pick a row and a column number to pick a column in that row.

VLOOKUP(search-for, columns-range, return-column, close-match)

  • search-for: The value to find. search-value can contain any value type.
  • columns-range: A range of cells. range is a reference to a single range of cells, which may contain values of any type.
  • return-column: A number that specifies the relative column number of the cell from which to return the value. return-column is a number value. The leftmost column in the range is column 1.
  • close-match: An optional value that determines whether an exact match is required.
    • close match (TRUE, 1, or omitted): If there’s no exact match, select the column with the largest top-row value that is less than the search value. Wildcards can’t be used in search-for.
    • exact match (FALSE or 0): If there’s no exact match, return an error. Wildcards can be used in search-for.


Your first formula is returning the result you asked for (although not the resut you wanted):

User uploaded file


Translated into English, the formula says:


Search for the value contained in cell C2 (of this table),

Search in the first column of the table consisting of cells A2 to F25 of Table 3,

Return the value in from the column indicated by the value in the cell in this row of the column labeled "H-Power_Inp_Rated,

Argument 4 has been omitted, so a "Close Match" with C2 is acceptable


The 3rd argument, shown in italics in the translation, is the one giving you trouble.


You have used a cell reference here, stating only the column containing the cell. Since the argument requires a single value, Numbers automatically interprets the short reference as a reference to the cell in the same row of that column as occupied by the formula (row 2 in this case), and uses the value contained by that cell as the 3rd argument.


The cell referenced is Cell E2 on Table 3, which contains the value 1.05. The argument requires an integer value greater than zero, so 1.05 is truncated to 1, and the formula returns the value from column 1 of the lookup table; the model number for the unit.


Revising the formula:


For Cell G2 (the position of the formula shown in your first example), you want the value from column E of the lokup table (Table 3). That's the fifth column of the table (A is 1), so the value of the 3rd argument must be 5:


G2: =VLOOKUP(C2, Table 3::A2:F25, 5)


Specifying the value directly means you'll have to change that value (manually) for each column. A better way is to calculate the value, using the COLUMN() function. Column G, where this occurrence of the formula is located, is column 7. Subtract 2 from that, and the result is 5, the value we want for this argument. New version of the formula:


G2: =VLOOKUP($C2, Table 3::A2:F25, COLUMN()-2)


The nice thing about this version is that because you want the data pulled in in the same column order as it is listed on the lookup table, you can place this formula into any cell in row 2, and it will return the correct result.

Note the $ operator added before the C in C2. This keeps that cell reference fixed on column C as the formula is filled right or left.


Enter the formula in D2, then fill it right to H2. With all five cells selected, fill down for as many rows as you need.


Regards,

Barry


PS: Apple provides two excellent resources with Numbers, the Numbers '09 User Guide and the iWork Formulas and Functions User Guide. Chapters 1 to 4 of the numbers guide are highly recommended as 'required reading' for anyone new to Numbers. The rest of that guide, and the F&F guide should be treated as handy references to be consulted when the need arises.


Both are searchable PDF documents, and both are available to download through the Help menu in Numbers.


B

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

VLOOKUP is returning incorrect column values

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.