I want to sort a list of names & addresses by surname. The data is laid out as follows: surname1is in a1,address in b1,b2,b3 surname2 in a4, address in b4,b5,b6. etc.
So basically I want to sort by column a, but keeping the addresses in col b attached to the correct surnames.
Been playing around with group/outline, but I don’t think the solution lies there.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
outline/group (97)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » outline/group (97)
- This topic has 3 replies, 4 voices, and was last updated 23 years, 5 months ago.
AuthorTopicWScormac9
AskWoody LoungerDecember 10, 2001 at 4:47 pm #363974Viewing 2 reply threadsAuthorReplies-
WSWassim
AskWoody LoungerDecember 10, 2001 at 5:15 pm #557262cormac9
To sort this kind of list properly you need to have something in the empty cells (A2 and A3 and B5 and B6) in your example.
I suggest you use a separate column with a series of numbers in 3s. Something like a series 1,1,1,2,2,2,3,3,3… and sort by that column to keep all the addresses together and using the A Column to sort alphabetically.
Hope this helps.
Wassim
-
WSdcardno
AskWoody LoungerDecember 10, 2001 at 7:00 pm #557326I can see two choices. If you sort on the file as it sits now the blank cells in column A (A2:A3, A5:A6, etc) will all group together in the sort – and the data in the coresponding cells in column B will no longer be associated with the correct name in column A. The technical term is unprintable in a family forum, but it will not be fun! (been there, incompetent clerical help has done that!).
You can either associate each of those cells with the correct name by copying the name information to the appropriate cells in column A, or you could put all the information in one row by moving the second and third address lines to the same row as the name and first line of the address. I recommend the latter, but lets deal with both techniques
To do the first one, you can use a little VBA routine as follows:
Sub FillBlank() Dim Cell As Range For Each Cell In Selection If Cell.Formula = "" Then Cell.Value = Cell.Offset(-1, 0).Value Next Cell End Sub
Select the relevant range in column A (ie – all the cells that have address values in column
and run the macro – it steps through the selection and drops the value found in the cell immediately above into any blank cell. In my opinion this looks horrible, but at least you will be able to sort the file and get meanigful results.
A much better alternative is to put all the required information onto one line. Put the following formulas in your s/sheet without the quotation marks:
in C1: "=b2" in D1: "=b3"
then select the range C1:D3 and copy it down the length of active cells in column B. Every fourth row in column C and D will have a formula placing the address information on a single row, with blanks in the intervening rows. Copy and then Paste Special | Values to transform the formulas into string values. Finally, if you sort the file on column A all the rows with blanks in column A will be sorted together. They are now redundant, and can be deleted. You will have names and addresses sortable by name (or by city, post code, etc if the address lines were normally laid out).
The advantage of this approach is that this format is much easier to use as a mailmerge source for Word – which is likely where you will want to use it in any event!
-
WSJohnBF
AskWoody LoungerDecember 10, 2001 at 7:05 pm #557328There are a few ways to go, and if you need to maintain this format, VBA may be best. However, the attached file shows a quick-&-dirty, one-time change to restructure your data into pure columns, after which the sorting is easy.
Sheet1 is how I understand your data is now laid out, Sheet2 restructures it using formulas, Sheet3 takes the formulas and copies the data over the formulas by using Edit, Paste Special, Values.
All that remains to be done is sorting the entire data, and then you ignore the “left over” address fields in column B.
If this won’t do it, let us know what you need.
Viewing 2 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
18 minutes ago -
Auto Time Zone Adjustment
by
wadeer
3 hours, 53 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
1 hour, 32 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
45 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
46 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
43 minutes ago -
Apps included with macOS
by
Will Fastie
1 hour, 34 minutes ago -
Xfinity home internet
by
MrJimPhelps
38 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
2 hours, 48 minutes ago -
Debian 12.11 released
by
Alex5723
1 day, 1 hour ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 4 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
8 hours, 9 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
33 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
1 day, 21 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 12 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
2 days ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 16 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
1 day ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
2 hours, 4 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 9 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
2 days, 6 hours ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 20 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
2 days, 23 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 7 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
20 hours, 20 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
3 days, 2 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
3 days, 2 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 days, 15 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 10 hours ago -
0Patch, where to begin
by
cassel23
3 days, 4 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.