2) Automate Task - Street Order

pavimeus

New Member
Joined
Nov 4, 2002
Messages
45
I am hoping to automate three Excel tasks that we routinely perform. Right now it’s a bit tedious and repetitious to perform. I’m sure it requires some macro programming.

Basically, it’s for a marketing company that maintains client lists containing company name, contact, address, city, county, state and zip code, as well as phone number.

Here is the second task. (First task titled Automate Task – Data De-dupe posted earlier).

2) Automate Task - Street Order

In this task, we are concerned with the street order of our client lists. The street address is contained in a single field. I need to be able to sort this field by the street name. This is because our sales associates often embark on visits to our clients (personal meetings). Quite often there are multiple businesses within the same street to visit. Instead of bouncing back and fort and traveling all over the place, it would be ideal if they had a list in street order. For example, 123 Any St., followed by 124 Any St., followed by 125 Any St., etc., rather than 123 Any St., then 123 2nd St., then 456 3rd St., then 1234 Any St, etc.

Here’s how I manually accomplish this task right now, with my very amateur skills and knowledge. I’m sure there’s an easier way.

Fifteen separate sales associates provide daily feedbacks of client lists containing the above fields on an Excel spreadsheet. I copy all fifteen spreadsheets on to one master file/spreadsheet. I separate the address fields into pieces by highlighting the column, selecting Data à Text to Columns, and then using the wizard, selecting Delimited in Step 1, checking Space in Step 2, and then Finish. For example, this step will separate 123 Any St. Suite 456, contained in one single cell, into five separate cells.

I then re-merge fields two, three, four and five (i.e. the street address only without the unit no.), so that “123” is one cell and all of “Any St. Suite 456” is in another cell. This is accomplished using the formula =concatenate(cell2,“ ”,cell3, “ ”,cell4, “ ”,cell5).

I then sort the entire spreadsheet by zip code first, then street address, then unit no., in ascending order. Now I have a list in proper street order, in every city.

I didn’t mean to ramble on, I was hoping that this detailed description would also help you to understand what exactly it is that I want to accomplish. How do I automate this task? If there’s an easier way to accomplish any of this, I’m open to ideas.

Thank you very much.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi

Have a search on the Board for 'combine' or 'consolidate' workbooks - it's a popular subject. You could also trying recording a macro as you do small steps. Go to Tools > Macro > Record New Macro, start the recorder, complete your actions then stop the recorder. Although the recorder includes unecessary code it will generally do the job. If you have problems with that post back and someone will help you. Things like the sort and Text to Columns can be done with code and the result assigned to a button.

Again, if you try something and have a problem, post back - plenty of experts here will give you a hand.

Hope this gives you some ideas.

Regards
 
Upvote 0
Hello pavimeus
Your examples only showed Str number and Street Name , even though you discussed sorting Zip codes etc. , so my example only shows a method of seperating street number from street name and then sorting by street name.

ASSUMPTIONS:
1) Street addresses are found in column A of the activeSheet
2) Street addresses are constants , eg. not formula based
3) column B is empty , ready to recieve str name
4) The prefix to all street names is a street number


Sub ParseAndSortAddresses()

'Parse Address
For Each Addr In Columns("A:A").SpecialCells(xlCellTypeConstants, 2)
FullAddr = Trim(Addr)
CommaPos = InStr(1, FullAddr, " ")
StrNum = Left(FullAddr, CommaPos - 1)
StrAddr = Mid(FullAddr, CommaPos + 1, Len(FullAddr))
Addr.Value = StrNum
Addr.Offset(0, 1).Value = StrAddr
Next Addr


' Sort by Street Addr
Columns("A:B").Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
 
Upvote 0
I am just delirious with joy!! Thank you, thank you, thank you!! This is brilliant, awesome, exciting, wonderful!! I was playing around with your solutions (and doing a little jig at the same time) and can't wait to try it out for real at work, on Monday.

Glaswegian – what a beautiful and simple solution! It works!! Record Macro function is good enough for my needs for now but I am very much interested in learning macro programming now (does macro programming in Excel generally mean VB??).

I used a sample of 1000 records to work your suggestion. How do I set the Record Macro to start at the beginning, and end at the end (???). If I pasted another spreadsheet, this time with 2000 records, Run Macro only recognizes the first 1000, since I recorded only 1000 (no?).

Nimrod – I mentioned sorting zip codes because it is a factor in the sort itself. The purpose of putting the spreadsheet in street order so as to assist the sales associates in their actual client visits, only works if the streets are within the same city/zip code. For example, we want to avoid 123 Main St., Town1, Zip 12345, and the next record being 123 Main St., Town2, Zip 12346.

Thank you soooo much for your code!!! I can still use your code, can’t I? I have a few questions and will post them here in due course.

This is a fantabulous site!
 
Upvote 0
BTW – I should have stated this earlier. I have Office 2000 working on Windows ME at home, and Office 97 off Windows 98 at work.
 
Upvote 0
Hi pavimeus

The macro recorder does have it's limitations. As you described, it recognised that you wanted to work with 1000 records, but it does not know when you want to change that number. Post the code you have from the recorder and let us know what you require. Someone will be able to help.

Regards
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,718
Members
452,939
Latest member
WCrawford

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