PC Review


Reply
Thread Tools Rate Thread

Developing a macro that will help with mass address cleansing

 
 
Jordan
Guest
Posts: n/a
 
      6th Mar 2008
Hi there,

I am trying to develop a macro which performs a mass find/replace of
numbered street suffixes. For example:

"1st" = "1"
"2nd" = "2"
..
..
..
"3th" = "3'"

I am fairly familiar with VBA. However I have not really used it in the
excel environment before. So far I have created a user form that asks the
user to input the column in which the address field is located (A, B, C,
etc...) and then I have written some code to select that column. The next
step would be to loop through this column to find the street suffixes and
replace them with their substitutions. I am assuming I would now have to use
the Find() and Replace() functions to do this, but I am having a bit of a
hard time doing this. So here is what I have so far.

------------------------------------------------
Private Sub CB1_Click()
Dim AddressRange As Range
Dim sUserRange As String

sUserRange = TB1.Text

ActiveSheet.Columns(sUserRange).Select

End Sub
------------------------------------------------

Its not much, but I do not know how to use the find/replace functions.

Any help would be excellent.

Jordan

 
Reply With Quote
 
 
 
 
cht13er
Guest
Posts: n/a
 
      7th Mar 2008
I hope there's a good reason that you're not selecting the entire
sheet / specific columns and doing a CTRL+F and replace....

Anywho ..

Private Sub CB1_Click()
Dim AddressRange As Range
Dim sUserRange As String

sUserRange = TB1.Text 'keep in mind that this text should be an
integer
ActiveSheet.Columns(sUserRange).Select 'now you have selected
column(s)

Selection.Replace What:="1st", Replacement:="2", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False

Selection.Replace What:="2nd", Replacement:="2", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False

Selection.Replace What:="3rd", Replacement:="2", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False,
_
ReplaceFormat:=False

End Sub


That's the simplest way (without knowing about the data you're working
with).

Remember, to learn more about code in excel, tools->macro->record new
macro ... do whatever .. hit 'stop' ... go into VB Editor (Alt+F11)
and see what's going on

Chris
On Mar 6, 4:25 pm, Jordan <Jor...@discussions.microsoft.com> wrote:
> Hi there,
>
> I am trying to develop a macro which performs a mass find/replace of
> numbered street suffixes. For example:
>
> "1st" = "1"
> "2nd" = "2"
> .
> .
> .
> "3th" = "3'"
>
> I am fairly familiar with VBA. However I have not really used it in the
> excel environment before. So far I have created a user form that asks the
> user to input the column in which the address field is located (A, B, C,
> etc...) and then I have written some code to select that column. The next
> step would be to loop through this column to find the street suffixes and
> replace them with their substitutions. I am assuming I would now have to use
> the Find() and Replace() functions to do this, but I am having a bit of a
> hard time doing this. So here is what I have so far.
>
> ------------------------------------------------
> Private Sub CB1_Click()
> Dim AddressRange As Range
> Dim sUserRange As String
>
> sUserRange = TB1.Text
>
> ActiveSheet.Columns(sUserRange).Select
>
> End Sub
> ------------------------------------------------
>
> Its not much, but I do not know how to use the find/replace functions.
>
> Any help would be excellent.
>
> Jordan


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help developing a Excel VBA Macro to Vaildate data entered intoa textbox macro rewind Microsoft Excel Programming 5 27th Nov 2009 10:12 AM
Request for Help in Developing a Macro for a Billing Application Steve Microsoft Excel Programming 10 28th Feb 2008 10:06 PM
Mass Replace of Address George.Conley@fnf.com Microsoft Outlook Contacts 3 14th Apr 2007 03:04 AM
Developing macro event to allow multiple choices on drop down menu =?Utf-8?B?QnJlbmRhbg==?= Microsoft Excel Worksheet Functions 2 6th Jul 2006 04:31 PM
How to mass email but sender only see their address =?Utf-8?B?RGFuaWVsbGU=?= Microsoft Outlook Discussion 1 26th Sep 2005 06:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:06 AM.