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.
Co...
- Apr 04, 2018This formula will do the job
=IF(ISNUMBER(SEARCH("Inbound",B2)),D2,IF(ISNUMBER(SEARCH("Outbound",B2)),C2,""))
Jamil
Apr 04, 2018Bronze Contributor
This formula will do the job
=IF(ISNUMBER(SEARCH("Inbound",B2)),D2,IF(ISNUMBER(SEARCH("Outbound",B2)),C2,""))
=IF(ISNUMBER(SEARCH("Inbound",B2)),D2,IF(ISNUMBER(SEARCH("Outbound",B2)),C2,""))
- Laura CheepingApr 04, 2018Copper Contributor
Thanks, this worked!
- Haytham AmairahApr 04, 2018Silver 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
- JamilApr 04, 2018Bronze ContributorYou are welcome.