if function problem need solving

determinedtoexceed

New Member
Joined
Aug 20, 2019
Messages
38
Dear Pros,

Please help me with 1 function that can determine whether there is any gap by item name.

example1: For itemA, "Cell E1" will show "No Gap" if b1,c1,d1 all are"No Gap"

example2: For itemA, "Cell E1" will show "Gap to 1st" when b1 ="Gap to 1st" while C1 and D1 ="No Gap"

example3: For itemA, "Cell E1" will show " Gap to 1st&Gap to 3rd" when B1=Gap to 1st, C1=No Gap, D1=Gap to 3rd

Thank you very much for your time~

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]itemA[/TD]
[TD]Gap to 1st[/TD]
[TD]No Gap[/TD]
[TD]Gap to 3rd[/TD]
[TD]:)[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]itemB[/TD]
[TD]No Gap[/TD]
[TD]Gap to 2nd[/TD]
[TD]Gap to 3rd[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Re: if funcction problem need solving

Will you only have these three columns (B, C, and D), or is this a simplified example and might you have more than 3 columns?
 
Upvote 0
Re: if funcction problem need solving

If there are only three, try this formula:
Code:
=IF(COUNTIF(B1:D1,"No Gap")=3,"No Gap",SUBSTITUTE(TRIM(IF(B1<>"No Gap",B1&" ","")&IF(C1<>"No Gap",C1&" ","")&IF(D1<>"No Gap",D1,""))," G","&G"))
 
Upvote 0
Re: if funcction problem need solving

If there are only three, try this formula:
Code:
=IF(COUNTIF(B1:D1,"No Gap")=3,"No Gap",SUBSTITUTE(TRIM(IF(B1<>"No Gap",B1&" ","")&IF(C1<>"No Gap",C1&" ","")&IF(D1<>"No Gap",D1,""))," G","&G"))
If there are only three, try this formula:
Code:
=IF(COUNTIF(B1:D1,"No Gap")=3,"No Gap",SUBSTITUTE(TRIM(IF(B1<>"No Gap",B1&" ","")&IF(C1<>"No Gap",C1&" ","")&IF(D1<>"No Gap",D1,""))," G","&G"))

Dear Joe4,

You are correct, it is indeed a simplified example, I do have more than 3 columns and when i apply the function base on methodology you provided, it did not work.

sample B1 actually locate on U10,
sample C1 actually locate on AA10
sample D1 actuly located on AG10

sample E1 result cell actually located on Q10

"NO GAP""GAP to xx" are also returned if functions


Function show blank when
Q10=IF(COUNTIF(U:AG,"NO GAP")=13,"NO GAP",SUBSTITUTE(TRIM(IF(U10<>"NO GAP",U10&" ","")&IF(AA10<>"NO GAP",AA10&" ","")&IF(AG10<>"NO GAP",AG10,""))," G","&G"))

Please help~ and thank you very much.
 
Upvote 0
Re: if funcction problem need solving

Can you Try My Formula
Code:
=INDEX({"Gap to 1st & Gap to 3rd"," Gap to 2nd  & Gap to 3rd","Gap to 1st & Gap to 2nd ","No Gap "},MATCH(B1&" "&C1&" "&D1,{"Gap to 1st No Gap Gap to 3rd","No Gap Gap to 2nd Gap to 3rd","Gap to 1st Gap to 2nd No Gap","No Gap No Gap No Gap"},0))

ABCDE
ItemAGap to 1stNo GapGap to 3rd
ItemBNo GapGap to 2ndGap to 3rd
ItemCGap to 1stGap to 2ndNo Gap
ItemDNo GapNo GapNo Gap

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]Gap to 1st & Gap to 3rd[/TD]

[TD="align: center"]2[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "] Gap to 2nd & Gap to 3rd[/TD]

[TD="align: center"]3[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]Gap to 1st & Gap to 2nd [/TD]

[TD="align: center"]4[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] "]No Gap [/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]E1[/TH]
[TD="align: left"]=INDEX({"Gap to 1st & Gap to 3rd"," Gap to 2nd & Gap to 3rd","Gap to 1st & Gap to 2nd ","No Gap "},MATCH(B1&" "&C1&" "&D1,{"Gap to 1st No Gap Gap to 3rd","No Gap Gap to 2nd Gap to 3rd","Gap to 1st Gap to 2nd No Gap","No Gap No Gap No Gap"},0))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Re: if funcction problem need solving

Can you Try My Formula
Code:
=INDEX({"Gap to 1st & Gap to 3rd"," Gap to 2nd  & Gap to 3rd","Gap to 1st & Gap to 2nd ","No Gap "},MATCH(B1&" "&C1&" "&D1,{"Gap to 1st No Gap Gap to 3rd","No Gap Gap to 2nd Gap to 3rd","Gap to 1st Gap to 2nd No Gap","No Gap No Gap No Gap"},0))

ABCDE
ItemAGap to 1stNo GapGap to 3rdGap to 1st & Gap to 3rd
ItemBNo GapGap to 2ndGap to 3rd Gap to 2nd & Gap to 3rd
ItemCGap to 1stGap to 2ndNo GapGap to 1st & Gap to 2nd
ItemDNo GapNo GapNo GapNo Gap

<tbody>
[TD="align: center"]1[/TD]

[TD="align: center"]2[/TD]

[TD="align: center"]3[/TD]

[TD="align: center"]4[/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH]E1[/TH]
[TD="align: left"]=INDEX({"Gap to 1st & Gap to 3rd"," Gap to 2nd & Gap to 3rd","Gap to 1st & Gap to 2nd ","No Gap "},MATCH(B1&" "&C1&" "&D1,{"Gap to 1st No Gap Gap to 3rd","No Gap Gap to 2nd Gap to 3rd","Gap to 1st Gap to 2nd No Gap","No Gap No Gap No Gap"},0))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
Dear Salim, it will return error when C1 return Gap to 2nd

I think there are more than 10 outcomes for E1 when b,c,d are triggered
 
Upvote 0
Re: if funcction problem need solving

If this doesn't work, could we please have a few sets of more realistic sample dummy data, including where that data is located & the expected results
This is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}. The formula can then be copied down.

Excel Workbook
QRSTUVWXYZAAABACADAEAFAG
10Gap to 1st & Gap to 3rdGap to 1stNo GapGap to 3rd
11No GapNo GapNo GapNo Gap
12Gap to 1st & Gap to 2nd & Gap to 3rdGap to 1stGap to 2ndGap to 3rd
13Gap to 2ndNo GapGap to 2ndNo Gap
Gap
 
Upvote 0
Re: if funcction problem need solving

You are correct, it is indeed a simplified example, I do have more than 3 columns and when i apply the function base on methodology you provided, it did not work.
That is the danger of oversimplifying things. You get a reply that answers the exact question you asked, but doesn't really solve your problem!
For that reason, it is best NOT to oversimplify things, and give us an accurate depiction of the data you are working with.

I see that Peter has provided you with a solution, so hopefully that will work for you.
 
Last edited:
Upvote 0
Re: if funcction problem need solving

Thank you all for taking the time and helping me out to solve my problem.

All your effort is deeply appreciated.
:)
 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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