How to find and replace characters within a cell

subzeroheart

New Member
Joined
Aug 20, 2014
Messages
1
Please help me.

I have an address in a cell for example - [TABLE="width: 193"]
<tbody>[TR]
[TD="width: 193"]2215 Nw 36th St

I need to search and find only Nw and change it to NW.

The same goes for Dr, Us, Ne, St, Ste, Blvd and Dr

How do I accomplish this in a macro?

Thank you for your help in advance[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Code:
Sub sample()
Dim x(1 To 10) As Variant
x(1) = "Nw"
x(2) = "Dr"
x(3) = "Us"
x(4) = "Ne"
x(5) = "St"
x(6) = "Ste"
x(7) = "Blvd"
For i = 1 To 7
    Range("a1").Value = Replace(Range("a1").Value, x(i), UCase(x(i)))
Next
End Sub
 
Upvote 0
Please help me.

I have an address in a cell for example - [TABLE="width: 193"]
<tbody>[TR]
[TD="width: 193"]2215 Nw 36th St

I need to search and find only Nw and change it to NW.

The same goes for Dr, Us, Ne, St, Ste, Blvd and Dr

How do I accomplish this in a macro?

Thank you for your help in advance[/TD]
[/TR]
</tbody>[/TABLE]
Welcome to the board.

Select all the cells you want to change, then run this macro.
Code:
Sub ReplaceList()
Dim myList As Variant
myList = Array("Nw", "Dr", "Us", "Ne", "St", "Ste", "Blvd")
With Selection
    For i = LBound(myList) To UBound(myList)
        .Replace what:=myList(i), replacement:=UCase(myList(i)), lookat:=xlPart, MatchCase:=False
    Next i
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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