Return a value if a condition is met

manojrf

Board Regular
Joined
Mar 28, 2011
Messages
109
Hi friends,


I have been trying to figure out the solution to find a formula to return a value if a letter or word is repeated 2 times in range.


For example :


Sheet1

ABCDEF
SBNUIS
H

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]

</tbody>


Excel tables to the web >> Excel Jeanie HTML 4






As shown above, the letter "S" is repeated 2 times in Row 1. What I am trying to do is to make a formula to put "H" in Row 2 below the second "S" (found in F1).


I have tried countif, count, rept and so on. But couldn't make one.


Can anyone please help me?

Hope someone would help me.


Thanks in advance.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I assume you're putting the formula in all cells across row 2.
If you use

=IF(COUNTIF($A$1:A$1,A1)>1,"H","")

That should work.

Sheet1

ABCDEF
SBNUIS
H

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

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

</tbody>


Excel tables to the web >> Excel Jeanie HTML 4






As shown above, the letter "S" is repeated 2 times in Row 1. What I am trying to do is to make a formula to put "H" in Row 2 below the second "S" (found in F1).


I have tried countif, count, rept and so on. But couldn't make one.


Can anyone please help me?

Hope someone would help me.


Thanks in advance.[/QUOTE]
 
Upvote 0
Hi,

Forgot to tell that the letters in Row 1 may get scrambled and so the position of the letter S may change.

Actually I am trying to put the letter H in Row 2, below the second and fourth S (which is Row 1)

For eg:

Sheet1

ABCDEFGHIJKL

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]S[/TD]
[TD="align: center"]I[/TD]
[TD="align: center"]X[/TD]
[TD="align: center"]S[/TD]
[TD="align: center"]P[/TD]
[TD="align: center"]S[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]Q[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]U[/TD]
[TD="align: center"]S[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]

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

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

</tbody>


Excel tables to the web >> Excel Jeanie HTML 4



Excel tables to the web >> Excel Jeanie HTML 4

Thanks in advance.
 
Last edited:
Upvote 0
Thanks TrySomethingNew & CyrusTheVirus. Thanks for the reply.

From the hint TrySomethingNew gave me, I have found out the formula I was looking for.

Sheet1

ABCDEFGHIJKL

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"><col style="width:64px;"></colgroup><tbody>
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]1[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]S[/TD]
[TD="align: center"]I[/TD]
[TD="align: center"]X[/TD]
[TD="align: center"]S[/TD]
[TD="align: center"]P[/TD]
[TD="align: center"]S[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]Q[/TD]
[TD="align: center"]Y[/TD]
[TD="align: center"]U[/TD]
[TD="align: center"]S[/TD]

[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=cacaca]#cacaca[/URL] , align: center"]2[/TD]

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

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

</tbody>

Spreadsheet Formulas
CellFormula
A2=IF(COUNTIF($A$1:A$1,A1)=2,"H",IF(COUNTIF($A$1:A$1,A1)=4,"H",""))
B2=IF(COUNTIF($A$1:B$1,B1)=2,"H",IF(COUNTIF($A$1:B$1,B1)=4,"H",""))
C2=IF(COUNTIF($A$1:C$1,C1)=2,"H",IF(COUNTIF($A$1:C$1,C1)=4,"H",""))
D2=IF(COUNTIF($A$1:D$1,D1)=2,"H",IF(COUNTIF($A$1:D$1,D1)=4,"H",""))
E2=IF(COUNTIF($A$1:E$1,E1)=2,"H",IF(COUNTIF($A$1:E$1,E1)=4,"H",""))
F2=IF(COUNTIF($A$1:F$1,F1)=2,"H",IF(COUNTIF($A$1:F$1,F1)=4,"H",""))
G2=IF(COUNTIF($A$1:G$1,G1)=2,"H",IF(COUNTIF($A$1:G$1,G1)=4,"H",""))
H2=IF(COUNTIF($A$1:H$1,H1)=2,"H",IF(COUNTIF($A$1:H$1,H1)=4,"H",""))
I2=IF(COUNTIF($A$1:I$1,I1)=2,"H",IF(COUNTIF($A$1:I$1,I1)=4,"H",""))
J2=IF(COUNTIF($A$1:J$1,J1)=2,"H",IF(COUNTIF($A$1:J$1,J1)=4,"H",""))
K2=IF(COUNTIF($A$1:K$1,K1)=2,"H",IF(COUNTIF($A$1:K$1,K1)=4,"H",""))
L2=IF(COUNTIF($A$1:L$1,L1)=2,"H",IF(COUNTIF($A$1:L$1,L1)=4,"H",""))

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4

I appreciate the time you have spent for me.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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