Home » excel » excel – Match value then return value of cell to left or right

# excel – Match value then return value of cell to left or right

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a range of cells that have different values. I would like to match values of cell but return the values of cell either to the left or right. For simplicity, let’s just say I want the cell 1 column to the left: Would appreciate any pointers

How to&Answers:

use the following:

``````=INDEX(\$A\$1:\$F\$8,INT(AGGREGATE(15,6,(ROW(\$A\$3:\$F\$8)+(COLUMN(\$A\$3:\$F\$8)/1000))/(\$A\$3:\$F\$8=\$B\$10),ROW(1:1))),INT(AGGREGATE(15,6,(COLUMN(\$A\$3:\$F\$8)+(ROW(\$A\$3:\$F\$8)/1000))/(((ROW(\$A\$3:\$F\$8)+(COLUMN(\$A\$3:\$F\$8)/1000))=AGGREGATE(15,6,(ROW(\$A\$3:\$F\$8)+(COLUMN(\$A\$3:\$F\$8)/1000))/(\$A\$3:\$F\$8=\$B\$10),ROW(1:1)))*(\$A\$3:\$F\$8=\$B\$10)),1)-1))
`````` ### Answer：

Since VLookup only works if your key is the leftmost item in the range and even then only if the range is a flat table from top to bottom, I think you can only do this using VBA. If your data is always exactly that format, you could also simply hardcode one row at the bottom with a specific cell at the top, if it matches the lookup value write the data, then filter the rows to remove errors/empty cells.

In VBA you just specify the starting point of your lookup data, loop through the cells (either down or to the right, then wrap around when you reach emptyness until you’re not finding any more data), compare the cell value to your lookup calue and if it matches, write the data entry at the bottom.