# retrieve value from column based on separate column

#### dhx10000

##### Board Regular
I have a worksheet that contains data similar to this:

A B
--------- -------------
578 22395
578 22395
625 37553
703 37553
811 49995
811 49995
823 49995

-----------------------------------------------------
I have another sheet where I am trying to do this:

G H
----- --------
578 22395
625 37553
703 37553
811 49995
823 49995

I already know how to generate the "G" column. I am having problems generating the "H" column

Thank you

### Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

#### iggydarsa

##### Well-known Member
you can use VLOOKUP function

#### dhx10000

##### Board Regular
I have a correction to make, what if columns A and B are reversed? Because that is how my data is. I don't think VLOOKUP will work.

#### iggydarsa

##### Well-known Member
That's a good point... I never tried reverse search... Now you made me wonder too...

#### dhx10000

##### Board Regular
This is excellent. The last piece of my puzzle is that sometimes my VLOOKUP is returning a 0 in my H column because the H column contains some blanks. Is there any way to tell the VLOOKUP funtion to only return the first non-blank value it comes across, per value in G?

A B
-- --
578
578
578 22995
625
625 36150
735 37555
855 39562

This would in turn look like this:

G H
-- --
578 22995
625 36150
735 37555
855 39562

#### NateO

##### Legend
The safest thing to do might be (if it's random, or you might not find a match) would be to make a copy of your data, then delete the blanks in column B, then do your lookup, e.g., delete code:

Code:
``````Sub foo()
Range("b:b").SpecialCells(xlBlanks).EntireRow.Delete
End Sub``````

#### dhx10000

##### Board Regular
Thank you, this will do just fine

Replies
1
Views
120
Replies
1
Views
328
Replies
1
Views
107
Replies
4
Views
450
Replies
6
Views
291

1,195,948
Messages
6,012,475
Members
441,701
Latest member
vnkendijs

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back