Segregating Data based on varying number of columns

murexcel

New Member
Joined
Jan 4, 2020
Messages
19
Office Version
  1. 2010
Platform
  1. Windows
Hi, we're undertaking a data collection drive for a community project. We have a data collection software that records data in below format.

Book1
ABCDEFGHIJKLMNOPQRSTUV
1GROUP IDFLATBUILDING NAMESTATUSMALE1MALE1 IDMALE2MALE2 IDMALE3MALE3 IDFEMALE1ID1FEMALE2 ID2FEMALE3ID3CHILD1ID1CHILD2ID2CHILD3ID3
21234105ABCDYESMR. X123456MR. Y123457MR. Z123458MS. X11111MS. Y8888MS. Z7777MSTR X9999MSTR Y7777MSTR Z5555
31235106ABCDYESMR.X122336MS. X22222MSTR X79654
Sheet1



We need that data to be segregated in the below format.

Book1
ABCDEFG
1GROUP IDFLATBUILDING NAMESTATUSIDNAMEGENDER
21234105ABCDYES123456MR. XMALE1
3123457MR. YMALE2
4123458MR. ZMALE3
511111MS. XFEMALE1
68888MS. YFEMALE2
77777MS. ZFEMALE3
89999MSTR XCHILD1
97777MSTR YCHILD2
105555MSTR ZCHILD3
11
121235105ABCDYES122336MR. XMALE1
1322222MS. XFEMALE1
1479654MSTR XCHILD1
Sheet2


The problem is that the data columns from E would vary based on the number of members, so we need a formula that ignores blanks and segregates data in the above format.

We tried a couple of things, but weren't able to achieve the desired results. Any help is greatly appreciated.


EDIT:
Would also like to add that the number of columns after E are not fixed. There could be n number of members for each gender type.
 
Last edited by a moderator:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Segregating Data based on varying number of columns
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Hi, see in the linked files (with 4 tech worksheets) a possible solution for Office 2010...

The formulas used in the tables...
tech1!A2: =LOWER(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(INDEX(Source!$1:$1,,ROW())," ",""),"0",""),"1",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9","")) (Range: A2:A50 ...)
tech1!B2: =IF(A2="","",IF(OR(A2="male",A2="female",A2="child"),1,0)) (Range: B2:B50 ...)
tech1!C2: =IF(A2="","",IF(B2=0,0,SUM(B$2:B2))) (Range: C2:C50 ...)
tech1!D2: =SUM(B:B)+4
tech2!E2: =IF(INDEX(tech1!$A:$A,COLUMN())="","",IF(AND(INDEX(tech1!$B:$B,COLUMN())=1,INDEX(tech1!$B:$B,COLUMN()+1)=0),IF(OR(INDEX(Source!2:2,COLUMN())="",INDEX(Source!2:2,COLUMN()+1)=""),0,1),0)) (Range: E2:BB30 ...)
tech3!A2: =SUM(D:D)
tech3!B2: =IF(Source!A2="","",1) (Range: B2:B30 ...)
tech3!C2: =IF(B2="","",SUM(B$2:B2)) (Range: C2:C30 ...)
tech3!D2: =IF(B2="","",MAX(SUM(tech2!2:2),1)+1) (Range: D2:D30 ...)
tech3!E2: =IF(B2="","",SUM(D$1:D1)+2) (Range: E2:E30 ...)
tech4!E2: =IF(INDEX(tech1!$A:$A,COLUMN())="","",IF(tech3!$B2="","",IF(tech2!E2=0,0,SUM(tech2!$E2:E2)))) (Range: E2:BB30 ...)
Segregating!A2: =IF(ROW()>tech3!A$2,"",IFERROR(INDEX(Source!A:A,INDEX(tech3!C:C+1,MATCH(ROW(),tech3!E:E,0))),"")) (Range: A2:A30 ...)
Segregating!B2: =IF(ROW()>tech3!A$2,"",IFERROR(INDEX(Source!B:B,INDEX(tech3!C:C+1,MATCH(ROW(),tech3!E:E,0))),"")) (Range: B2:B30 ...)
Segregating!C2: =IF(ROW()>tech3!A$2,"",IFERROR(INDEX(Source!C:C,INDEX(tech3!C:C+1,MATCH(ROW(),tech3!E:E,0))),"")) (Range: C2:C30 ...)
Segregating!D2: =IF(ROW()>tech3!A$2,"",IFERROR(INDEX(Source!D:D,INDEX(tech3!C:C+1,MATCH(ROW(),tech3!E:E,0))),"")) (Range: D2:D30 ...)
Segregating!E2: =IF(ROW()>tech3!A$2,"",IFERROR(INDEX(INDIRECT("Source!"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1&":"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1),MATCH(ROW()-INDEX(tech3!E:E,MATCH(ROW(),tech3!E:E))+1,INDIRECT("tech4!"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1&":"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1),0)+1),"")) (Range: E2:E30 ...)
Segregating!F2: =IF(ROW()>tech3!A$2,"",IFERROR(INDEX(INDIRECT("Source!"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1&":"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1),MATCH(ROW()-INDEX(tech3!E:E,MATCH(ROW(),tech3!E:E))+1,INDIRECT("tech4!"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1&":"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1),0)),"")) (Range: F2:F30 ...)
Segregating!G2: =IF(ROW()>tech3!A$2,"",IFERROR(INDEX(Source!$1:$1,MATCH(ROW()-INDEX(tech3!E:E,MATCH(ROW(),tech3!E:E))+1,INDIRECT("tech4!"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1&":"&INDEX(tech3!C:C,MATCH(ROW(),tech3!E:E))+1),0)),"")) (Range: G2:G30 ...)

Segregating.xlsx
SegregatingN.xlsx

Source.png


tech1.png


tech2.png


tech3.png


tech4.png


Segregating.png



SourceN.png


SegregatingN.png
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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