Combining similar data across multiple rows!

comoke

New Member
Joined
Jun 20, 2019
Messages
2
Good evening!

I am working on combining several rows of data with similar ID numbers. I have a small example below. For reference, my data set is every possible combination of an origin/destination for the contiguous US, so 2,401 rows total. Also, I will need to do this several times in the future with different ID numbers, so a general solution would be most helpful.

Essentially, I need to combine states with similar ID numbers into something more useful based on similarities in ID number and groups for State 2. For example, the ID numbers starting at 24 have a repeating MT, ND, WY in State 2. So I would like some sort of output like this:

AL, AR, AZ CA in one cell.
MT, ND, WY in another cell.

Since each of AL, AR, AZ, CA, each are matched with MT, ND, and WY and also with the same ID number.

Is this something that can be done? I appreciate any help you can offer.

Thank you!


ID State 1 State 2
15 NC NC
15 WI KS
16 FL FL
17 UT CO
18 NM NM
19 RI KS
20 CA AZ
21 UT ID
22 CA NV
23 MO KS
24 AL MT
24 AL ND
24 AL WY
24 AR MT
24 AR ND
24 AR WY
24 AZ MT
24 AZ ND
24 AZ WY
24 CA MT
24 CA ND
24 CA WY
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Re: Help with combining similar data across multiple rows!

you mean like this?

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]ID[/td][td=bgcolor:#5B9BD5]State 1[/td][td=bgcolor:#5B9BD5]State 2[/td][td][/td][td=bgcolor:#70AD47]ID[/td][td=bgcolor:#70AD47]State 1[/td][td=bgcolor:#70AD47]State 2[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
15​
[/td][td=bgcolor:#DDEBF7]NC[/td][td=bgcolor:#DDEBF7]NC[/td][td][/td][td=bgcolor:#E2EFDA]
15​
[/td][td=bgcolor:#E2EFDA]NC WI[/td][td=bgcolor:#E2EFDA]NC KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
15​
[/td][td]WI[/td][td]KS[/td][td][/td][td]
16​
[/td][td]FL[/td][td]FL[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
16​
[/td][td=bgcolor:#DDEBF7]FL[/td][td=bgcolor:#DDEBF7]FL[/td][td][/td][td=bgcolor:#E2EFDA]
17​
[/td][td=bgcolor:#E2EFDA]UT[/td][td=bgcolor:#E2EFDA]CO[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
17​
[/td][td]UT[/td][td]CO[/td][td][/td][td]
18​
[/td][td]NM[/td][td]NM[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
18​
[/td][td=bgcolor:#DDEBF7]NM[/td][td=bgcolor:#DDEBF7]NM[/td][td][/td][td=bgcolor:#E2EFDA]
19​
[/td][td=bgcolor:#E2EFDA]RI[/td][td=bgcolor:#E2EFDA]KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
19​
[/td][td]RI[/td][td]KS[/td][td][/td][td]
20​
[/td][td]CA[/td][td]AZ[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
20​
[/td][td=bgcolor:#DDEBF7]CA[/td][td=bgcolor:#DDEBF7]AZ[/td][td][/td][td=bgcolor:#E2EFDA]
21​
[/td][td=bgcolor:#E2EFDA]UT[/td][td=bgcolor:#E2EFDA]ID[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
21​
[/td][td]UT[/td][td]ID[/td][td][/td][td]
22​
[/td][td]CA[/td][td]NV[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
22​
[/td][td=bgcolor:#DDEBF7]CA[/td][td=bgcolor:#DDEBF7]NV[/td][td][/td][td=bgcolor:#E2EFDA]
23​
[/td][td=bgcolor:#E2EFDA]MO[/td][td=bgcolor:#E2EFDA]KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
23​
[/td][td]MO[/td][td]KS[/td][td][/td][td]
24​
[/td][td]AL AL AL AR AR AR AZ AZ AZ CA CA CA[/td][td]MT ND WY MT ND WY MT ND WY MT ND WY[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AL[/td][td=bgcolor:#DDEBF7]MT[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AL[/td][td]ND[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AL[/td][td=bgcolor:#DDEBF7]WY[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AR[/td][td]MT[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AR[/td][td=bgcolor:#DDEBF7]ND[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AR[/td][td]WY[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AZ[/td][td=bgcolor:#DDEBF7]MT[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AZ[/td][td]ND[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AZ[/td][td=bgcolor:#DDEBF7]WY[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]CA[/td][td]MT[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]CA[/td][td=bgcolor:#DDEBF7]ND[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]CA[/td][td]WY[/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


or

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#70AD47]ID[/td][td=bgcolor:#70AD47]State 1[/td][td=bgcolor:#70AD47]State 2[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]
15​
[/td][td=bgcolor:#E2EFDA]NC WI[/td][td=bgcolor:#E2EFDA]NC KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
16​
[/td][td]FL[/td][td]FL[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]
17​
[/td][td=bgcolor:#E2EFDA]UT[/td][td=bgcolor:#E2EFDA]CO[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
18​
[/td][td]NM[/td][td]NM[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]
19​
[/td][td=bgcolor:#E2EFDA]RI[/td][td=bgcolor:#E2EFDA]KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
20​
[/td][td]CA[/td][td]AZ[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]
21​
[/td][td=bgcolor:#E2EFDA]UT[/td][td=bgcolor:#E2EFDA]ID[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
22​
[/td][td]CA[/td][td]NV[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]
23​
[/td][td=bgcolor:#E2EFDA]MO[/td][td=bgcolor:#E2EFDA]KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AL AR AZ CA[/td][td]MT ND WY[/td][/tr]
[/table]
 
Last edited:
Upvote 0
Re: Help with combining similar data across multiple rows!

Good morning sandy,

I'm more looking for this:

15 NC - NC
15 WI - KS
16 FL - FL
17 UT - CO
18 NM - NM
19 RI - KS
20 CA - AZ
21 UT - ID
22 CA - NV
23 MO - KS
24 AL AR AZ CA - MT ND WY

I need to enter it as a From State 1 To State 2 situation, so only the ones where they have the state combos in common, e.g. each of AL AR AZ CA are going to each of MT ND WY. But for 15 since only NC is going to NC and only WI is going to KS, they need to be separate.

Thanks for the question, I apologize if I didn't explain it well enough!
 
Upvote 0
Re: Help with combining similar data across multiple rows!

you mean like this?

[TABLE="class: head"]
<tbody>[TR]
[TD="bgcolor: #5B9BD5"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]ID[/COLOR][/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]State 1[/COLOR][/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]State 2[/COLOR][/TD]
[TD][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]ID[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]State 1[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]State 2[/COLOR][/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
15​
[/TD]
[TD="bgcolor: #DDEBF7"]NC[/TD]
[TD="bgcolor: #DDEBF7"]NC[/TD]
[TD][/TD]
[TD="bgcolor: #E2EFDA"]
15​
[/TD]
[TD="bgcolor: #E2EFDA"]NC WI[/TD]
[TD="bgcolor: #E2EFDA"]NC KS[/TD]
[/TR]
[TR]
[TD]
15​
[/TD]
[TD]WI[/TD]
[TD]KS[/TD]
[TD][/TD]
[TD]
16​
[/TD]
[TD]FL[/TD]
[TD]FL[/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
16​
[/TD]
[TD="bgcolor: #DDEBF7"]FL[/TD]
[TD="bgcolor: #DDEBF7"]FL[/TD]
[TD][/TD]
[TD="bgcolor: #E2EFDA"]
17​
[/TD]
[TD="bgcolor: #E2EFDA"]UT[/TD]
[TD="bgcolor: #E2EFDA"]CO[/TD]
[/TR]
[TR]
[TD]
17​
[/TD]
[TD]UT[/TD]
[TD]CO[/TD]
[TD][/TD]
[TD]
18​
[/TD]
[TD]NM[/TD]
[TD]NM[/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
18​
[/TD]
[TD="bgcolor: #DDEBF7"]NM[/TD]
[TD="bgcolor: #DDEBF7"]NM[/TD]
[TD][/TD]
[TD="bgcolor: #E2EFDA"]
19​
[/TD]
[TD="bgcolor: #E2EFDA"]RI[/TD]
[TD="bgcolor: #E2EFDA"]KS[/TD]
[/TR]
[TR]
[TD]
19​
[/TD]
[TD]RI[/TD]
[TD]KS[/TD]
[TD][/TD]
[TD]
20​
[/TD]
[TD]CA[/TD]
[TD]AZ[/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
20​
[/TD]
[TD="bgcolor: #DDEBF7"]CA[/TD]
[TD="bgcolor: #DDEBF7"]AZ[/TD]
[TD][/TD]
[TD="bgcolor: #E2EFDA"]
21​
[/TD]
[TD="bgcolor: #E2EFDA"]UT[/TD]
[TD="bgcolor: #E2EFDA"]ID[/TD]
[/TR]
[TR]
[TD]
21​
[/TD]
[TD]UT[/TD]
[TD]ID[/TD]
[TD][/TD]
[TD]
22​
[/TD]
[TD]CA[/TD]
[TD]NV[/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
22​
[/TD]
[TD="bgcolor: #DDEBF7"]CA[/TD]
[TD="bgcolor: #DDEBF7"]NV[/TD]
[TD][/TD]
[TD="bgcolor: #E2EFDA"]
23​
[/TD]
[TD="bgcolor: #E2EFDA"]MO[/TD]
[TD="bgcolor: #E2EFDA"]KS[/TD]
[/TR]
[TR]
[TD]
23​
[/TD]
[TD]MO[/TD]
[TD]KS[/TD]
[TD][/TD]
[TD]
24​
[/TD]
[TD]AL AL AL AR AR AR AZ AZ AZ CA CA CA[/TD]
[TD]MT ND WY MT ND WY MT ND WY MT ND WY[/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
24​
[/TD]
[TD="bgcolor: #DDEBF7"]AL[/TD]
[TD="bgcolor: #DDEBF7"]MT[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
24​
[/TD]
[TD]AL[/TD]
[TD]ND[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
24​
[/TD]
[TD="bgcolor: #DDEBF7"]AL[/TD]
[TD="bgcolor: #DDEBF7"]WY[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
24​
[/TD]
[TD]AR[/TD]
[TD]MT[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
24​
[/TD]
[TD="bgcolor: #DDEBF7"]AR[/TD]
[TD="bgcolor: #DDEBF7"]ND[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
24​
[/TD]
[TD]AR[/TD]
[TD]WY[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
24​
[/TD]
[TD="bgcolor: #DDEBF7"]AZ[/TD]
[TD="bgcolor: #DDEBF7"]MT[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
24​
[/TD]
[TD]AZ[/TD]
[TD]ND[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
24​
[/TD]
[TD="bgcolor: #DDEBF7"]AZ[/TD]
[TD="bgcolor: #DDEBF7"]WY[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
24​
[/TD]
[TD]CA[/TD]
[TD]MT[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DDEBF7"]
24​
[/TD]
[TD="bgcolor: #DDEBF7"]CA[/TD]
[TD="bgcolor: #DDEBF7"]ND[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
24​
[/TD]
[TD]CA[/TD]
[TD]WY[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


or

[TABLE="class: head"]
<tbody>[TR]
[TD="bgcolor: #70AD47"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]ID[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]State 1[/COLOR][/TD]
[TD="bgcolor: #70AD47"][COLOR=[URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF"]#FFFFFF[/URL] ]State 2[/COLOR][/TD]
[/TR]
[TR]
[TD="bgcolor: #E2EFDA"]
15​
[/TD]
[TD="bgcolor: #E2EFDA"]NC WI[/TD]
[TD="bgcolor: #E2EFDA"]NC KS[/TD]
[/TR]
[TR]
[TD]
16​
[/TD]
[TD]FL[/TD]
[TD]FL[/TD]
[/TR]
[TR]
[TD="bgcolor: #E2EFDA"]
17​
[/TD]
[TD="bgcolor: #E2EFDA"]UT[/TD]
[TD="bgcolor: #E2EFDA"]CO[/TD]
[/TR]
[TR]
[TD]
18​
[/TD]
[TD]NM[/TD]
[TD]NM[/TD]
[/TR]
[TR]
[TD="bgcolor: #E2EFDA"]
19​
[/TD]
[TD="bgcolor: #E2EFDA"]RI[/TD]
[TD="bgcolor: #E2EFDA"]KS[/TD]
[/TR]
[TR]
[TD]
20​
[/TD]
[TD]CA[/TD]
[TD]AZ[/TD]
[/TR]
[TR]
[TD="bgcolor: #E2EFDA"]
21​
[/TD]
[TD="bgcolor: #E2EFDA"]UT[/TD]
[TD="bgcolor: #E2EFDA"]ID[/TD]
[/TR]
[TR]
[TD]
22​
[/TD]
[TD]CA[/TD]
[TD]NV[/TD]
[/TR]
[TR]
[TD="bgcolor: #E2EFDA"]
23​
[/TD]
[TD="bgcolor: #E2EFDA"]MO[/TD]
[TD="bgcolor: #E2EFDA"]KS[/TD]
[/TR]
[TR]
[TD]
24​
[/TD]
[TD]AL AR AZ CA[/TD]
[TD]MT ND WY[/TD]
[/TR]
</tbody>[/TABLE]


Hi Sandy,

How do you include this Chat - i have tried many time to include like this cart with multiple colour how you have uploaded colour with Green & Blue.

Thanks - Nasmin
 
Last edited:
Upvote 0
Re: Help with combining similar data across multiple rows!

Hope this is what you want

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]ID[/td][td=bgcolor:#5B9BD5]State 1[/td][td=bgcolor:#5B9BD5]State 2[/td][td][/td][td=bgcolor:#70AD47]ID[/td][td=bgcolor:#70AD47]State 1[/td][td=bgcolor:#70AD47]State 2[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
15​
[/td][td=bgcolor:#DDEBF7]NC[/td][td=bgcolor:#DDEBF7]NC[/td][td][/td][td=bgcolor:#E2EFDA]
15​
[/td][td=bgcolor:#E2EFDA]NC[/td][td=bgcolor:#E2EFDA]NC[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
15​
[/td][td]WI[/td][td]KS[/td][td][/td][td]
15​
[/td][td]WI[/td][td]KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
16​
[/td][td=bgcolor:#DDEBF7]FL[/td][td=bgcolor:#DDEBF7]FL[/td][td][/td][td=bgcolor:#E2EFDA]
16​
[/td][td=bgcolor:#E2EFDA]FL[/td][td=bgcolor:#E2EFDA]FL[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
17​
[/td][td]UT[/td][td]CO[/td][td][/td][td]
17​
[/td][td]UT[/td][td]CO[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
18​
[/td][td=bgcolor:#DDEBF7]NM[/td][td=bgcolor:#DDEBF7]NM[/td][td][/td][td=bgcolor:#E2EFDA]
18​
[/td][td=bgcolor:#E2EFDA]NM[/td][td=bgcolor:#E2EFDA]NM[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
19​
[/td][td]RI[/td][td]KS[/td][td][/td][td]
19​
[/td][td]RI[/td][td]KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
20​
[/td][td=bgcolor:#DDEBF7]CA[/td][td=bgcolor:#DDEBF7]AZ[/td][td][/td][td=bgcolor:#E2EFDA]
20​
[/td][td=bgcolor:#E2EFDA]CA[/td][td=bgcolor:#E2EFDA]AZ[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
21​
[/td][td]UT[/td][td]ID[/td][td][/td][td]
21​
[/td][td]UT[/td][td]ID[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
22​
[/td][td=bgcolor:#DDEBF7]CA[/td][td=bgcolor:#DDEBF7]NV[/td][td][/td][td=bgcolor:#E2EFDA]
22​
[/td][td=bgcolor:#E2EFDA]CA[/td][td=bgcolor:#E2EFDA]NV[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
23​
[/td][td]MO[/td][td]KS[/td][td][/td][td]
23​
[/td][td]MO[/td][td]KS[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AL[/td][td=bgcolor:#DDEBF7]MT[/td][td][/td][td=bgcolor:#E2EFDA]
24​
[/td][td=bgcolor:#E2EFDA]AL AR AZ CA[/td][td=bgcolor:#E2EFDA]MT ND WY[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AL[/td][td]ND[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AL[/td][td=bgcolor:#DDEBF7]WY[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AR[/td][td]MT[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AR[/td][td=bgcolor:#DDEBF7]ND[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AR[/td][td]WY[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AZ[/td][td=bgcolor:#DDEBF7]MT[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]AZ[/td][td]ND[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]AZ[/td][td=bgcolor:#DDEBF7]WY[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]CA[/td][td]MT[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
24​
[/td][td=bgcolor:#DDEBF7]CA[/td][td=bgcolor:#DDEBF7]ND[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
24​
[/td][td]CA[/td][td]WY[/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group1 = Table.Group(Source, {"ID", "State 2"}, {{"Count", each _, type table}}),
    List1 = Table.AddColumn(Group1, "State 1", each List.Distinct(Table.Column([Count],"State 1"))),
    Extract1 = Table.TransformColumns(List1, {"State 1", each Text.Combine(List.Transform(_, Text.From), " "), type text}),
    RC1 = Table.RemoveColumns(Extract1,{"Count"}),
    Group2 = Table.Group(RC1, {"ID", "State 1"}, {{"Count", each _, type table}}),
    List2 = Table.AddColumn(Group2, "State 2", each List.Distinct(Table.Column([Count],"State 2"))),
    Extract2 = Table.TransformColumns(List2, {"State 2", each Text.Combine(List.Transform(_, Text.From), " "), type text}),
    RC2 = Table.RemoveColumns(Extract2,{"Count"})
in
    RC2[/SIZE]

Edit:
this is PowerQuery M-code, not any vba
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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