Lowggy

New Member
Joined
Mar 3, 2018
Messages
39
I have and excel file with about 200 rows. Consecutive columns have cells with last name, first name but in between those pairs of couple there are single names. I want to sort the file in alphabetical order keeping all the couples together and listing the single names at the end and of course keeping all the other columns in tact.
 
Yes this is exactly what I want, so I just add another column and flag all the individuals that are not part of a couple and the run the formula.
:confused: Run what formula?
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Yes this is exactly what I want, so I just add another column and flag all the individuals that are not part of a couple and the run the formula. Thanks again, your website and you individuals are extremely helpful. Randy

???

here is a M code for PowerQuery (Get&Transform)
there is no formula or something like that

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column3", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column3.1", "Column3.2"}),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Column3.1"}, {{"Count", each Table.RowCount(_), type number}, {"CAR", each _, type table}}),
    #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Count", Order.Descending}, {"Column3.1", Order.Ascending}}),
    #"Expanded CAR" = Table.ExpandTableColumn(#"Sorted Rows", "CAR", {"Column1", "Column2", "Column3.1", "Column3.2", "Column4", "Column5"}, {"Column1", "Column2", "Column3.1.1", "Column3.2", "Column4", "Column5"}),
    #"Merged Columns" = Table.CombineColumns(#"Expanded CAR",{"Column3.1.1", "Column3.2"},Combiner.CombineTextByDelimiter(", ", QuoteStyle.None),"Merged"),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Column3.1", "Count"})
in
    #"Removed Columns"[/SIZE]
 
Upvote 0
:confused: Run what formula?

I thought it was you, but I got a file showing my file with an additional column where there was a number 2 for all singles and a 1 for the couples with a formula to run at the top of the additional column.
it was not you?
 
Upvote 0
here is version with "flag". 1 = single (column: count)

Column1Column2CountMergedColumn4Column5
-1​
166​
2​
ALFORD, JIM
10​
9​
-1​
61​
2​
ALFORD, RUTH
19.5​
16​
-1​
39​
2​
ALMASI, CAROL*
19.1​
16​
-1​
181​
2​
ALMASI, DENNIS*
5.6​
5​
-1​
750​
2​
BADGER, JIM
16.7​
15​
-1​
749​
2​
BADGER, LYN
13.1​
11​
-1​
66​
2​
BEIERLE, BOB
9.2​
8​
-1​
210​
2​
BEIERLE, CAROLYN
20.1​
17​
-1​
99​
2​
BERGER, RHONDA
20.2​
17​
-1​
97​
2​
BERGER, TODD
18.2​
16​
-1​
352​
2​
BERGERON, LESLIE*
9.4​
8​
-1​
353​
2​
BERGERON, MAURICE*
17.5​
16​
-1​
18​
1​
ANDRIOLA, BETTY*
20.2​
17​
-1​
57​
1​
BARNABY, BUTCH
17.5​
16​
-1​
44​
1​
BAUER, RICHARD*
16.8​
15​
-1​
130​
1​
BELL, DON
16.6​
15​
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column3", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column3.1", "Column3.2"}),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Column3.1"}, {{"Count", each Table.RowCount(_), type number}, {"CAR", each _, type table}}),
    #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Count", Order.Descending}, {"Column3.1", Order.Ascending}}),
    #"Expanded CAR" = Table.ExpandTableColumn(#"Sorted Rows", "CAR", {"Column1", "Column2", "Column3.1", "Column3.2", "Column4", "Column5"}, {"Column1", "Column2", "Column3.1.1", "Column3.2", "Column4", "Column5"}),
    #"Merged Columns" = Table.CombineColumns(#"Expanded CAR",{"Column3.1.1", "Column3.2"},Combiner.CombineTextByDelimiter(", ", QuoteStyle.None),"Merged"),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Column3.1"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Column1", "Column2", "Count", "Merged", "Column4", "Column5"})
in
    #"Reordered Columns"[/SIZE]
 
Upvote 0
here is version with "flag". 1 = single (column: count)

[COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column1[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column2[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Count[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Merged[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column4[/COLOR][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Column5[/COLOR]
-1​
166​
2​
ALFORD, JIM
10​
9​
-1​
61​
2​
ALFORD, RUTH
19.5​
16​
-1​
39​
2​
ALMASI, CAROL*
19.1​
16​
-1​
181​
2​
ALMASI, DENNIS*
5.6​
5​
-1​
750​
2​
BADGER, JIM
16.7​
15​
-1​
749​
2​
BADGER, LYN
13.1​
11​
-1​
66​
2​
BEIERLE, BOB
9.2​
8​
-1​
210​
2​
BEIERLE, CAROLYN
20.1​
17​
-1​
99​
2​
BERGER, RHONDA
20.2​
17​
-1​
97​
2​
BERGER, TODD
18.2​
16​
-1​
352​
2​
BERGERON, LESLIE*
9.4​
8​
-1​
353​
2​
BERGERON, MAURICE*
17.5​
16​
-1​
18​
1​
ANDRIOLA, BETTY*
20.2​
17​
-1​
57​
1​
BARNABY, BUTCH
17.5​
16​
-1​
44​
1​
BAUER, RICHARD*
16.8​
15​
-1​
130​
1​
BELL, DON
16.6​
15​

<tbody>
</tbody>

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column3", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column3.1", "Column3.2"}),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Column3.1"}, {{"Count", each Table.RowCount(_), type number}, {"CAR", each _, type table}}),
    #"Sorted Rows" = Table.Sort(#"Grouped Rows",{{"Count", Order.Descending}, {"Column3.1", Order.Ascending}}),
    #"Expanded CAR" = Table.ExpandTableColumn(#"Sorted Rows", "CAR", {"Column1", "Column2", "Column3.1", "Column3.2", "Column4", "Column5"}, {"Column1", "Column2", "Column3.1.1", "Column3.2", "Column4", "Column5"}),
    #"Merged Columns" = Table.CombineColumns(#"Expanded CAR",{"Column3.1.1", "Column3.2"},Combiner.CombineTextByDelimiter(", ", QuoteStyle.None),"Merged"),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Column3.1"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Column1", "Column2", "Count", "Merged", "Column4", "Column5"})
in
    #"Reordered Columns"[/SIZE]
Ok I see your code now, thank you.
 
Upvote 0
I thought it was you, but I got a file showing my file with an additional column where there was a number 2 for all singles and a 1 for the couples with a formula to run at the top of the additional column.
it was not you?
What you quoted in post 10 was from Sandy666 so I assumed that your comments in that post were directed at him.

Post 9 was my suggestion for a manual approach. The formula in column F was to mark couples/multiples with a 1 and singles with a 2 and then manually sort the data. You said the easiest method and I thought that was easy.

Is that what you tried?
 
Upvote 0
ok, thanks everyone. I thought learning excel would be easier than this. Now i am having trouble sorting my file. I want to keep all the double rows together that are numbered 1 and 1, 2 and 2 with the associated names but I want to sort the file so that it comes out in ascending order of the value in column F. I tried several custom sorts that I thought should work but no luck.
Here is part of the file. low couple handicap being column F
GroupCouples Name, last then firstIndividual HandicapTotal Couple HandicapLow Couple Handicap
1ALFORD, JIM*9259
1ALFORD, RUTH*16
2ALMASI, CAROL*16215
2ALMASI, DENNIS*5
3BADGER, JIM*152611
3BADGER, LYN*11
4BEIERLE, BOB*8258
4BEIERLE, CAROLYN*17
5BERGER, RHONDA*173316
5BERGER, TODD*16
6BERGERON, LESLIE*8248
6BERGERON, MAURICE*16
7BOBE, DONNA*17258
7BOBE, LARRY*8
8BOSTWICK, CAROL*122210
8 DAVE FULMER10

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Sticking with a manual approach, try a formula like this in a vacant column then select all columns and sort on the new column.

Excel Workbook
BCDEFG
1GroupCouples Name, last then firstIndividual HandicapTotal Couple HandicapLow Couple Handicap
21ALFORD, JIM*92599001
31ALFORD, RUTH*169001
42ALMASI, CAROL*162155002
52ALMASI, DENNIS*55002
63BADGER, JIM*15261111003
73BADGER, LYN*1111003
84BEIERLE, BOB*82588004
94BEIERLE, CAROLYN*178004
105BERGER, RHONDA*17331616005
115BERGER, TODD*1616005
126BERGERON, LESLIE*82488006
136BERGERON, MAURICE*168006
147BOBE, DONNA*172588007
157BOBE, LARRY*88007
168BOSTWICK, CAROL*12221010008
178DAVE FULMER1010008
Sort
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,681
Members
449,116
Latest member
HypnoFant

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