Formula Required to Group Family Members, where ID matches

WednesdayC

Board Regular
Joined
Nov 7, 2010
Messages
201
Office Version
  1. 2016
Platform
  1. MacOS
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 10pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Georgia, sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { font-family: Calibri, sans-serif; }.xl64 { color: black; font-family: Verdana; text-align: right; border: 0.5pt solid rgb(170, 170, 170); }.xl65 { color: black; font-family: Verdana; text-align: left; border: 0.5pt solid rgb(170, 170, 170); }.xl66 { font-weight: 700; font-family: Calibri, sans-serif; }.xl67 { font-weight: 700; font-family: Calibri, sans-serif; text-align: center; }.xl68 { color: black; font-weight: 700; font-family: Verdana; text-align: left; border: 0.5pt solid rgb(170, 170, 170); }</style>Hi All

Can anyone help me please? I am trying to group family members, as follows:-

[TABLE="width: 477"]
<colgroup><col style="width:75pt" width="75" span="4"> <col style="mso-width-source:userset;mso-width-alt:6473;width:177pt" width="177"> </colgroup><tbody>[TR]
[TD="class: xl65, width: 75"]ID[/TD]
[TD="class: xl65, width: 75"]LAST NAME[/TD]
[TD="class: xl65, width: 75"]FIRST NAME[/TD]
[TD="class: xl66, width: 75"]Status[/TD]
[TD="class: xl67, width: 177"]RESULTS REQUIRED[/TD]
[/TR]
[TR]
[TD="class: xl68"]84[/TD]
[TD="class: xl69"]Doe[/TD]
[TD="class: xl69"]Joe[/TD]
[TD="class: xl69"]Employee[/TD]
[TD="class: xl70"]EMPLOYEE[/TD]
[/TR]
[TR]
[TD="class: xl68"]88[/TD]
[TD="class: xl69"]Smith[/TD]
[TD="class: xl69"]Alan[/TD]
[TD="class: xl69"]Employee[/TD]
[TD="class: xl70"]EMPLOYEE[/TD]
[/TR]
[TR]
[TD="class: xl68"]192[/TD]
[TD="class: xl69"]Jones[/TD]
[TD="class: xl69"]Jack[/TD]
[TD="class: xl69"]Employee[/TD]
[TD="class: xl70"]EMPLOYEE, SPOUSE + 3 CHILDREN[/TD]
[/TR]
[TR]
[TD="class: xl68"]192[/TD]
[TD="class: xl69"]Jones[/TD]
[TD="class: xl69"]Emma[/TD]
[TD="class: xl69"]spouse[/TD]
[TD="class: xl70"] [/TD]
[/TR]
[TR]
[TD="class: xl68"]192[/TD]
[TD="class: xl69"]Jones[/TD]
[TD="class: xl69"]John[/TD]
[TD="class: xl69"]child[/TD]
[TD="class: xl70"] [/TD]
[/TR]
[TR]
[TD="class: xl68"]192[/TD]
[TD="class: xl69"]Jones[/TD]
[TD="class: xl69"]Jane[/TD]
[TD="class: xl69"]child[/TD]
[TD="class: xl70"] [/TD]
[/TR]
[TR]
[TD="class: xl68"]192[/TD]
[TD="class: xl69"]Jones[/TD]
[TD="class: xl69"]Jessica[/TD]
[TD="class: xl69"]child[/TD]
[TD="class: xl70"] [/TD]
[/TR]
[TR]
[TD="class: xl68"]195[/TD]
[TD="class: xl69"]Davies[/TD]
[TD="class: xl69"]Mark[/TD]
[TD="class: xl69"]Employee[/TD]
[TD="class: xl70"]EMPLOYEE[/TD]
[/TR]
[TR]
[TD="class: xl68"]197[/TD]
[TD="class: xl69"]Lewis[/TD]
[TD="class: xl69"]Evan[/TD]
[TD="class: xl69"]Employee[/TD]
[TD="class: xl70"]EMPLOYEE, SPOUSE + 1 CHILD[/TD]
[/TR]
[TR]
[TD="class: xl68"]197[/TD]
[TD="class: xl69"]Lewis[/TD]
[TD="class: xl69"]Maria[/TD]
[TD="class: xl69"]spouse[/TD]
[TD="class: xl70"] [/TD]
[/TR]
[TR]
[TD="class: xl68"]197[/TD]
[TD="class: xl69"]Lewis[/TD]
[TD="class: xl69"]Victor[/TD]
[TD="class: xl69"]child[/TD]
[TD="class: xl70"] [/TD]
[/TR]
[TR]
[TD="class: xl68"]199[/TD]
[TD="class: xl69"]Clark[/TD]
[TD="class: xl69"]Kevin[/TD]
[TD="class: xl69"]Employee[/TD]
[TD="class: xl70"]EMPLOYEE[/TD]
[/TR]
</tbody>[/TABLE]
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 10pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Georgia, sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { font-family: Calibri, sans-serif; }.xl64 { font-weight: 700; font-family: Calibri, sans-serif; }.xl65 { font-weight: 700; font-family: Calibri, sans-serif; text-align: center; border: 0.5pt solid windowtext; }.xl66 { color: black; font-weight: 700; font-family: Verdana; text-align: left; border: 0.5pt solid windowtext; }.xl67 { font-weight: 700; font-family: Calibri, sans-serif; border: 0.5pt solid windowtext; }.xl68 { color: black; font-family: Verdana; text-align: right; border: 0.5pt solid windowtext; }.xl69 { color: black; font-family: Verdana; text-align: left; border: 0.5pt solid windowtext; }.xl70 { font-family: Calibri, sans-serif; border: 0.5pt solid windowtext; }</style>

Is it possible to do this with a regular formula, or would I require a UDF please?

I am not sure how to tackle this please, so would be very grateful for your expert guidance.

Many thanks in advance

Wednesday
<style>table { }td { padding-top: 1px; padding-right: 1px; padding-left: 1px; color: black; font-size: 10pt; font-weight: 400; font-style: normal; text-decoration: none; font-family: Georgia, sans-serif; vertical-align: bottom; border: medium none; white-space: nowrap; }.xl63 { font-family: Calibri, sans-serif; }.xl64 { color: black; font-family: Verdana; text-align: right; border: 0.5pt solid rgb(170, 170, 170); }.xl65 { color: black; font-family: Verdana; text-align: left; border: 0.5pt solid rgb(170, 170, 170); }.xl66 { font-weight: 700; font-family: Calibri, sans-serif; }.xl67 { font-weight: 700; font-family: Calibri, sans-serif; text-align: center; }.xl68 { color: black; font-weight: 700; font-family: Verdana; text-align: left; border: 0.5pt solid rgb(170, 170, 170); }</style>
 
Hi,

If you're still interested in a Formula solution (last sample - employee #200 - has no Spouse & 1 Child):


Book1
ABCDE
1IDLAST NAMEFIRST NAMEStatusRESULTS REQUIRED
284DoeJoeEmployeeEMPLOYEE
388SmithAlanEmployeeEMPLOYEE
4192JonesJackEmployeeEMPLOYEE, SPOUSE + 3 CHILDREN
5192JonesEmmaspouse
6192JonesJohnchild
7192JonesJanechild
8192JonesJessicachild
9195DaviesMarkEmployeeEMPLOYEE
10197LewisEvanEmployeeEMPLOYEE, SPOUSE + 1 CHILD
11197LewisMariaspouse
12197LewisVictorchild
13199ClarkKevinEmployeeEMPLOYEE
14200BearPapaEmployeeEMPLOYEE + 1 CHILD
15200BearBabychild
Sheet393
Cell Formulas
RangeFormula
E2=IF(COUNTIF(A$2:A2,A2)=1,SUBSTITUTE("EMPLOYEE"&IF(COUNTIFS(A$2:A$15,A2,D$2:D$15,"spouse"),", SPOUSE","")&IF(COUNTIFS(A$2:A$15,A2,D$2:D$15,"child")," + "&COUNTIFS(A$2:A$15,A2,D$2:D$15,"child")&" CHILDREN",""),"1 CHILDREN","1 CHILD"),"")


Change/adjust cell references/range as needed, formula copied down.
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
@ Fluff,

I would think to adjust your UDF for cases of Single Parents...
 
Upvote 0
Wow Jtakw

This is fantastic! Thank you so much.
You spotted that I forgot to account for cases where there are children and no spouses, and your formula even takes care of that scenario. I did adapt Fluff's UDF to account for that, but this formula is less volatile, so I will be using this solution instead.

How on earth you came up with it is beyond me. Huge thanks.

Regards
Wednesday
 
Upvote 0
You're welcome, glad it works for you.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

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