trying to expand vlookup to other cells without au

2019-09-15 23:11发布

I am setting up a vlookup to pull product prices from another sheet within the workbook. The code works for the cell but when i try to expand or copy and past the code into the next row it automatically changes the data table_array value.

=VLOOKUP(B5,Prices!1:65536,3)

Within the code i want the first value, B5 to scale with the row it is in, however the second value needs to remain the same. How do i go about doing this? Also is there a way that i can get the cell to remain blank instead of displaying N/A if there isnt a valid part number?

Thanks for your help!

3条回答
一纸荒年 Trace。
2楼-- · 2019-09-15 23:46

For the second part, an IF formula will work fine:

=IF(ISERROR(VLOOKUP(B5,Prices!1:65536,3)),"",VLOOKUP(B5,Prices!1:65536,3)),"")

And if I understand correctly the first part have you tried set an absolute value? Something like:

    =IF(ISERROR(VLOOKUP(B$5,Prices!1:65536,3)),"",VLOOKUP(B5,Prices!1:65536,3)),"")
查看更多
乱世女痞
3楼-- · 2019-09-15 23:46

I can't comment because I do not have enough rep but this will fix user3716271 's formula:

=IF(ISERROR(VLOOKUP(B5,Prices!$1:$65536,3)),"", VLOOKUP(B5,Prices!$1:$65536,3))

The following formula should solve both problems as well, a little more compact and would use one less VLOOKUP():

=IFERROR(VLOOKUP(B5,Prices!$1:$65536,3), "")

As guitarthrower had said, the $ before the number is used to lock the range.

查看更多
ゆ 、 Hurt°
4楼-- · 2019-09-15 23:51
=VLOOKUP(B5,Prices!$1:$65536,3)

The $ lock the range.

For example.

  • $A1 will lock the column to A when the formulas is copied other locations.
  • A$1 will lock the row
  • $A$1 will lock both the column and the row.
查看更多
登录 后发表回答