Is There a Way to Convert This Logic to a Formula?

meppwc

Well-known Member
Joined
May 16, 2003
Messages
626
Office Version
  1. 365
Platform
  1. Windows
Can the logic below be made into a formula?

Formula in cell U2
If S2 is blank and T2 is blank then U2 is blank
If S2 is populated and T2 is blank the map S2 to U2
If S2 is populated and T2 is populated, then map S2 to U2
If S2 is blank and T2 is populated, then map T2 to U2
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try:
Code:
=IF(AND(S2="",T2=""),"",IF(S2="",T2,S2))
 
Upvote 0
beaten 2 it
 
Last edited:
Upvote 0
How does your formula return a blank instead of 0 when both S2 & T2 are blank?
Just follow the logic.

If S2 is blank, the IF part with return T2, which is blank ("") and then it concatenates another blank ("").
This second blank concatenation coerces it to text instead of numeric, so it will return a blank and not a zero.
Try it and see!
 
Last edited:
Upvote 0
I tried and it works.

but when I enter this
Code:
[COLOR=#FF0000]=0&""[/COLOR]
it gives me zero as a result. why does the blank not coerce it to text in this case?
Just amazed and confused.
 
Upvote 0
I tried and it works.

but when I enter this
Code:
[COLOR=#FF0000]=0&""[/COLOR]
it gives me zero as a result. why does the blank not coerce it to text in this case?
Just amazed and confused.
Because you're giving it an actual "0". If you start with an empty cell, and add the &"", you get the empty cell, and the &"" makes sure that it's treated as text, not a number. A funny quirk of Excel is that if you do any LOOKUP function, and what you're looking up is an empty cell, Excel returns a 0. But the original cell is still empty.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top