Need help with an excel lookup looking at two colums

I have a XLS workbook with two sheets

Data & WBS

In Data column A is my OppID and in column C I want a vlookup to look in sheet WBS and if DATA column A = WBS column A then grab column B from WBS, but if column C in WBS is not blank grab that instead.
Matt PinkstonEnterprise ArchitectAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Would be easier with examples but in principle you can put the following in Data column c and copy down (this assumes row 1 is header and row 2 is start of data and there are 999 rows in WBS):-

=if("wbs"!c2 <> "", "wbs"!c2,vlookup("data"!A2,"wbs"!$a$2:$B$999,2,0))

note that Vlookup always returns the first matching value it comes across so WBS!A needs to be unique and, preferably, sorted
Matt PinkstonEnterprise ArchitectAuthor Commented:
got an error

A - OppID
C - cell for formula

A - OppID
B - code1
C - code2

when DATA A has a match in column A in sheet WBS grab column B unless there is a value in column c
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
I doubt if I have understood your requirement correctly...

You may try this to see if this is what you are trying to achieve.

On DATA Sheet,
In B2


Open in new window

The above formula will look for DATA!A2 in WBS!A:A and if a match found, it will return the corresponding value from WBS!C:C if it is not blank else it will return WBS!B:B and if no match is found it will return a blank.

If this is not you are after, please upload a sample workbook with the desired output shown manually.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
in your Data worksheet, column C1, try put:


Open in new window

ah - I didn't realise you were trying to choose between formulae. (example workbook would help!).

Ryan's submission is the equivalent
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.