Return a value if a condition is met

manojrf

Board Regular
Joined
Mar 28, 2011
Messages
107
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
1SBNUIS
2 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>
</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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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
1SBNUIS
2H

<tbody>
</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
1ASIXSPSEQYUS
2 H 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;"><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>
</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
1ASIXSPSEQYUS
2 H 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;"><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>
</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,215,635
Messages
6,125,946
Members
449,275
Latest member
jacob_mcbride

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