IF function with multiple criteria including a LEFT and INDEX/MATCH

sjames1066

New Member
Joined
Apr 17, 2013
Messages
3
Hi all,

Help would be gratefully received in my current excel dilemma.

In my sheet I'm looking for a formula which gives me either 1 or 2 initials of a first name depending on whether the surname appears more than once and if the first name has the same first letter i.e.

B
Surname
C
Firstname
D
Initial
BloggsTimothyT
BloggsRebeccaR
JonesBillBi
JonesBobBo

<tbody>
</tbody>



=IF(COUNTIFS(B:B, B16>1,C:C, LEFT(INDEX(C:C, MATCH(C16,C:C,0),0),1)), LEFT(C16, 2), LEFT(C16, 1))


Thanks,

SJ
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
One way would be:
Excel 2010
ABC
1SurnameFirstnameInitial
2BloggsTimothyT
3BloggsRebeccaR
4JonesBillBi
5JonesBobBo
6

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=IF(SUMPRODUCT(--(LEFT($B$2:$B$5,1)=LEFT(B2,1)))=1,LEFT(B2,1),LEFT(B2,2))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Thanks for the quick reply, although that example results in 2 initials for Timothy?

EDIT: I played around with the formula you gave Robert, and got it to work for single surnames but the duplicates still giving just one initial letter rather than 2

=IF(SUMPRODUCT(--(LEFT(B:B,1)=LEFT(B19,1)))=1,LEFT(C19,2),LEFT(C19,1))
 
Last edited:
Upvote 0

Excel 2010
ABC
1SurnameFirstnameInitial
2BloggsTimothyT
3BloggsRebeccaR
4JonesBillBi
5JonesBobBo
6tuttt
7tfagg
8
Sheet1
Cell Formulas
RangeFormula
C2=IF(SUMPRODUCT(--(LEFT($B$2:$B$10,1)=LEFT(B2,1))*(LEFT($A$2:$A$10,1)=LEFT(A2,1)))=1,LEFT(B2,1),LEFT(B2,2))
 
Upvote 0
Thanks for the quick reply, although that example results in 2 initials for Timothy?

EDIT: I played around with the formula you gave Robert, and got it to work for single surnames but the duplicates still giving just one initial letter rather than 2

Needs some tweaking...

D2, just enter and copy down:

=LEFT(C2,1+(SUMPRODUCT(--($B$2:$B$5=B2),--(LEFT($C$2:$C$5)=LEFT(C2)))>1))
 
Upvote 0
Re: SOLVED! IF function with multiple criteria including a LEFT and INDEX/MATCH

Thanks so much guys for your time on this!!

Turns out this worked perfectly:

=LEFT(C2,1+(SUMPRODUCT(--($B:$B=B2),--(LEFT($C:$C)=LEFT(C2)))>1))

I can finally go to bed now! Thanks so so much! :)
 
Upvote 0
Re: SOLVED! IF function with multiple criteria including a LEFT and INDEX/MATCH

Thanks so much guys for your time on this!!

Turns out this worked perfectly:

=LEFT(C2,1+(SUMPRODUCT(--($B:$B=B2),--(LEFT($C:$C)=LEFT(C2)))>1))

I can finally go to bed now! Thanks so so much! :)

You are welcome. I wouldn't want to disturb you sleep, but we need some qualifications. The solution offered won't work when:

Kad, Timothy
Kad, Tiffany
Kad, Titiana

Although such might be rare events, it's better to be aware of.
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,605
Members
449,038
Latest member
Arbind kumar

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