1

I am using Excel's VLOOKUP() first time and I am having hard time with it. Here is the screenshot:

enter image description here

I wrote a formula to cell B8; =VLOOKUP(C8, $A$2:$C$5, IF(C8 = "W", 2,3))

I was expecting as a result 1, but I am getting the wrong result 0.25. Am I doing something wrong?

Thanks for the help!

4

3 回答 3

9

vlookup 在表的最左列中查找一个值,然后从找到搜索值的行中返回一个值(该行的距离由您确定)。

在您的示例情况下,您需要在下面的第 4 部分中添加(NearOrExact)

vlookup公式由4部分组成:

1. SearchFor this is the value that is being searched for. 

2. WhereToSearch this is the range in which to search and in which the answer lives. 

3. WhichColumn this is the column in the WhereToSearch range which has the answer in it. 

4. NearOrExact you decide whether the vlookup should search for a close value or an exact value.

vlookup 公式的结构: =vlookup ( SearchFor , WhereToSearch , WhichColumn , NearOrExact )

来自 < http://www.excelvlookuphelp.com/how-to-use-vlookup/ >

于 2015-06-03T02:00:30.937 回答
3

你非常接近,vlookup 首先获取查找值,所以将第一个 C8 更改为 A8

编辑:正如 Barry Houdini 在评论中指出的那样,还要添加 FALSE 作为第四个参数

于 2013-09-15T04:56:43.697 回答
0

Sub IsoscelesTriangle1_Click() Dim finder As Worksheet, dataws As Worksheet Dim goallastrow As Long, datalastrow As Long, x As Long Dim datarng As Range

设置 finder = ThisWorkbook.Worksheets("Sheet2") 设置 dataws = ThisWorkbook.Worksheets("Sheet1")

目标lastrow = finder.Range("A" & Rows.Count).End(xlUp).Row datalastrow = dataws.Range("A" & Rows.Count).End(xlUp).Row

设置 datarng = dataws.Range("A2:C" & datalastrow)

For x = 2 Togoalslastrow On Error Resume Next finder.Range("C" & x).Value = Application.WorksheetFunction.VLookup(_finder.Range("A" & x).Value, datarng, 2, False)

下一个 x

For x = 2 Togoalslastrow On Error Resume Next finder.Range("i" & x).Value = Application.WorksheetFunction.VLookup(_finder.Range("A" & x).Value, datarng, 3, False)

下一个 x

结束子

对于 vba

于 2021-01-05T08:40:18.100 回答