Forum Discussion
Laura Cheeping
Apr 04, 2018Copper Contributor
Excel Formula - formula based on if cell contains
Please help! I am trying to create a formula that will do the following: If cell B2 contains "Inbound" then return data in cell D2, if cell B2 contains "Outbound" then return data in cell C2.
Column B2 will only contain Inbound or Outbound. I tried below formulas but they are not working.
=IF(ISNUMBER(SEARCH("Inbound",B7)),C7,D7)
=IF(B3="Inbound",D3,IF(B3="Outbound",C3,""))
- This formula will do the job
=IF(ISNUMBER(SEARCH("Inbound",B2)),D2,IF(ISNUMBER(SEARCH("Outbound",B2)),C2,""))
- JamilBronze ContributorThis formula will do the job
=IF(ISNUMBER(SEARCH("Inbound",B2)),D2,IF(ISNUMBER(SEARCH("Outbound",B2)),C2,""))- Laura CheepingCopper Contributor
Thanks, this worked!
- Haytham AmairahSilver Contributor
Hi Laura,
If the second formula didn't work, I guess that there are some leading spaces around the Inbound and Outbound texts!
If so, you can solve this with TRIM function as follows:
=IF(TRIM(B2)="Inbound",D2,IF(TRIM(B2)="Outbound",C2,""))
But if the Inbound or Outbound is part of a text such as (Outbound flight), you can use the formula suggested by Jamil.
Regards
- Haytham AmairahSilver Contributor
Hi Laura,
The second formula is what you are looking for, it's should work just fine!
But you have to change the cell references inside the formula from B3, D3, and C3 to B2, D2, and C2 as follows:
=IF(B2="Inbound",D2,IF(B2="Outbound",C2,""))
Hope that helps