How to copy and sort a range of names from a list

Jeddo

Board Regular
Joined
Jan 26, 2019
Messages
50
Office Version
  1. 2019
Platform
  1. Windows
I have a data base with names and I am needing to find all the names within a range (H - L for example), copy them to another range and sort them in alphabetical order. Novice with Excel. Tried doing a search with the greater than and lesser than signs, but cna't get the syntax right or even the formula right. I have mastered copying everything and sorting it alphabetically in a new range, just can't figure out how to pull out a range of names
AlphaHotel
TangoIndia
HotelJuliet
OscarKilo
WhiskeyLima
Bravo
Juliet
Quebec
X-Ray
Mike
Foxtrot
Lima
Zulu
Charlie
Kilo
Romeo
Victor
Delta
India
Papa
Uniform
Yankee
Echo
Golf
November
Sierra
[/RANGE
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
@Jeddo you have displayed 3 different columns, but you have asked for a 5 column range in your question.

Exactly what columns do you want sorted? Do you want each of them sorted independently?
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
@Jeddo you have displayed 3 different columns, but you have asked for a 5 column range in your question.

Exactly what columns do you want sorted? Do you want each of them sorted independently?
My apologies. Should have done a lot better job with my example. Still trying to learn. My ultimate goal is to separate column A into four groups; A-G, H-L, M-R and S-Z, into four different ranges. Also, each name will have data with it, such as first name and address. I was hoping if I can get the formula to find and sort one group, I could figure out the rest myself. I redid the example to give a better idea.

A-GH-LM-RS-Z
Last NameFirst NameAddressLast NameFirst NameAddressLast NameFirst NameAddressLast NameFirst NameAddressLast NameFirst NameAddress
AlphaJamesAustinAlphaJamesAustinHotelSuzyHoustonMikeLeeCut n shootSierraRexHutto
TangoKarenDallasBravoRickyWacoIndiaCarolBryanNovemberDustinFlatoniaTangoKarenDallas
HotelSuzyHoustonCharlieJohnThorndaleJulietAnnFort WorthOscarKenCisternUniformSamCaldwell
OscarKenCisternDeltaJimmyBeaumontKiloCharlesCotullaPapaKimberlyCameronVictorRobbieGalveston
WhiskeyBennySan AntonioEchoLukeSchulenbergLimaPaulRowlettQuebecAmyAbileneWhiskeyBennySan Antonio
BravoRickyWacoFoxtrotMikeParisRomeoMatthewLaredoX-RayAdamEl Paso
JulietAnnFort WorthGolfRonShinerYankeeMarkLa Grange
QuebecAmyAbileneZuluDaveRound Rock
X-RayAdamEl Paso
MikeLeeCut n shoot
FoxtrotMikeParis
LimaPaulRowlett
ZuluDaveRound rock
CharlieJohnThorndale
KiloCharlesCotulla
RomeoMatthewLaredo
VictorRobbieGalveston
DeltaJimmyBeaumont
IndiaCarolBryan
PapaKimberlyCameron
UniformSamCaldwell
YankeeMarkLa Grange
EchoLukeSchulenberg
GolfRonShiner
NovemberDustinFlatonia
SierraRexHutto
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Perhaps you missed Peter's comments/request here.
Some of the newer versions of Excel have some pretty cool new functions that can be used, but we do not want to suggest formulas that you cannot use.
So if you can update your account details to show us what version of Excel you are using, that would be most helpful!
 
Upvote 0
Perhaps you missed Peter's comments/request here.
Some of the newer versions of Excel have some pretty cool new functions that can be used, but we do not want to suggest formulas that you cannot use.
So if you can update your account details to show us what version of Excel you are using, that would be most helpful!
Ugh! Got busy making a new example and forgot all about that. Updated my account details. Would only let me enter year of the version I'm using. Using Office Professional Plus 2019
 
Upvote 0
I have mastered copying everything and sorting it alphabetically in a new range, just can't figure out how to pull out a range of names
You mention that you got the copy/sort piece working.
Can you tell us how you are doing that now, and maybe we can see if we can help you build on that?

Also, are you opposed to a VBA solution, if we were to offer that?
And do you have any issue if we re-sort the original list alphabetically, or does it need to stay the way that it is?
 
Upvote 0
A formula approach, if your happy with a helper column (which can always be hidden)
+Fluff 1.xlsm
ABCDEFGHIJKLMNOP
1A-GH-LM-RS-Z
2Last NameFirst NameAddressLast NameFirst NameAddressLast NameFirst NameAddressLast NameFirst NameAddressLast NameFirst NameAddress
3AlphaJamesAustin1AlphaJamesAustinHotelSuzyHoustonMikeLeeCut n shootSierraRexHutto
4TangoKarenDallas20BravoRickyWacoIndiaCarolBryanNovemberDustinFlatoniaTangoKarenDallas
5HotelSuzyHouston8CharlieJohnThorndaleJulietAnnFort WorthOscarKenCisternUniformSamCaldwell
6OscarKenCistern15DeltaJimmyBeaumontKiloCharlesCotullaPapaKimberlyCameronVictorRobbieGalveston
7WhiskeyBennySan Antonio23EchoLukeSchulenbergLimaPaulRowlettQuebecAmyAbileneWhiskeyBennySan Antonio
8BravoRickyWaco2FoxtrotMikeParis   RomeoMatthewLaredoX-RayAdamEl Paso
9JulietAnnFort Worth10GolfRonShiner      YankeeMarkLa Grange
10QuebecAmyAbilene17         ZuluDaveRound rock
11X-RayAdamEl Paso24            
12MikeLeeCut n shoot13            
13FoxtrotMikeParis6            
14LimaPaulRowlett12            
15ZuluDaveRound rock26            
16CharlieJohnThorndale3            
17KiloCharlesCotulla11            
18RomeoMatthewLaredo18            
19VictorRobbieGalveston22            
20DeltaJimmyBeaumont4            
21IndiaCarolBryan9
22PapaKimberlyCameron16
23UniformSamCaldwell21
24YankeeMarkLa Grange25
25EchoLukeSchulenberg5
26GolfRonShiner7
27NovemberDustinFlatonia14
28SierraRexHutto19
29
Main
Cell Formulas
RangeFormula
E3E3=IFERROR(INDEX($A$3:$A$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/(LEFT($A$3:$A$28)<="G")/($D$3:$D$28=ROWS(E$3:E3)),1)),"")
F3:G20F3=IF($E3="","",INDEX(B$3:B$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/($A$3:$A$28=$E3),COUNTIFS($E$3:$E3,$E3))))
H3:H20H3=IFERROR(INDEX($A$3:$A$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/(LEFT($A$3:$A$28)<="L")/(LEFT($A$3:$A$28)>="H")/($D$3:$D$28=ROWS(H$3:H3)+COUNTIFS($A$3:$A$28,"<H*")),1)),"")
I3:J20I3=IF($H3="","",INDEX(B$3:B$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/($A$3:$A$28=$H3),COUNTIFS($H$3:$H3,$H3))))
K3:K20K3=IFERROR(INDEX($A$3:$A$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/(LEFT($A$3:$A$28)<="r")/(LEFT($A$3:$A$28)>="m")/($D$3:$D$28=ROWS(H$3:H3)+COUNTIFS($A$3:$A$28,"<m*")),1)),"")
L3:M20L3=IF($K3="","",INDEX(B$3:B$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/($A$3:$A$28=$K3),COUNTIFS($K$3:$K3,$K3))))
N3:N20N3=IFERROR(INDEX($A$3:$A$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/(LEFT($A$3:$A$28)>="S")/($D$3:$D$28=ROWS(H$3:H3)+COUNTIFS($A$3:$A$28,"<s*")),1)),"")
O3:P20O3=IF($N3="","",INDEX(B$3:B$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/($A$3:$A$28=$N3),COUNTIFS($N$3:$N3,$N3))))
E4:E20E4=IFERROR(INDEX($A$3:$A$28,AGGREGATE(15,6,(ROW($A$3:$A$28)-ROW($A$3)+1)/(LEFT($A$3:$A$28)<="G")/(COUNTIFS($A$3:$A$28,"<"&$A$3:$A$28)=SMALL(COUNTIFS($A$3:$A$28,"<"&$A$3:$A$28),ROWS(E$3:E4))),1)),"")
D3:D28D3=COUNTIFS($A$3:$A$28,"<"&A3)+1
 
Upvote 0
You mention that you got the copy/sort piece working.
Can you tell us how you are doing that now, and maybe we can see if we can help you build on that?

Also, are you opposed to a VBA solution, if we were to offer that?
And do you have any issue if we re-sort the original list alphabetically, or does it need to stay the way that it is?
A VBA solution would be perfect. It's what I have been building this on, but first time and slow learner. Realized what I needed was basically a program for a phone or address book, found a YouTube video on how to, and have been building on that as I learn. This is the Macro I'm using to copy the original list to another range and sort it alphabetically. Just haven't figured out how to break it up into groups from there.

Sub Copy_Last_Name_3()
'
' Copy_Last_Name Macro
'
Sheets("phonelist").Select
Range("BQ8:BW233").Select
Selection.Copy
Range("CA8").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("CB8").Select
ActiveWorkbook.Worksheets("phonelist").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("phonelist").Sort.SortFields.Add Key:=Range( _
"CB9:CB233"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("phonelist").Sort
.SetRange Range("CB8:CG233")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("BT8").Select
End Sub



I have been able to use a search where I can get a group using the < or > sign before a letter. But I can't use both to get the groups in the middle. Here is that formula


Private Sub cmdContact_Click()

On Error GoTo errhandler:

Sheet1.Unprotect

Set DataSH = Sheet1

DataSH.Range("W8") = Me.cboSelect.Value
DataSH.Range("W9") = Me.txtSearch.Text

DataSH.Range("B8").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("phonelist!Criteria"), CopyToRange:=Range("phonelist!Extract"), Unique:=False

ListBox1.RowSource = Sheet1.Range("outdata").Address(External:=True)

Exit Sub
errhandler:
MsgBox "No Data Found. Please Try Again"

Sheet1.Protect

End Sub


I know some things aren't labeled correctly, but it what I learned from the video and I'm still trying to learn the proper syntax. Thanks for any help.
 
Upvote 0
Does Fluff's formula-based reply work for you, or would you still like to pursue a VBA option?

If VBA, please answer this earlier question I posted:
And do you have any issue if we re-sort the original list alphabetically, or does it need to stay the way that it is?
It will become much easier to do if we are able to re-sort the original list.
 
Upvote 0

Forum statistics

Threads
1,214,608
Messages
6,120,500
Members
448,968
Latest member
screechyboy79

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