howto replace the order of adress ?

  • Thread starter Thread starter ש×די
  • Start date Start date
×

ש×די

hi

i have rows that contain two shapes of adresses that i need to fix:
example1 : Rose street 25 4 Blabla ----> Rose street 4/25 Blabla
example2: Rose street 25/4 Blabla ----> Rose street 4/25 Blabla


thanks
 
hi

i have rows that contain two shapes of adresses that i need to fix:
example1 : Rose street 25 4 Blabla ----> Rose street 4/25 Blabla
example2: Rose street 25/4 Blabla ----> Rose street 4/25 Blabla


thanks

Given your specific format, the following Macro will do what you describe,
putting the altered results into the adjacent column. You can modify this in
many ways, depending on your specific requirements.

The critical part of your format is that the first string of digits separated
by either a <space> or a "/" will be reversed in place and separated by a "/"

==========================================
Option Explicit
Sub FixAdr()
Dim re As Object
Dim c As Range
Const sPat As String = "(\d+)[/\s]+(\d+)"
Const sRes As String = "$2/$1"

Set re = CreateObject("vbscript.regexp")
re.Pattern = sPat
For Each c In Selection
c.Offset(0, 1).Value = _
re.Replace(c.Text, sRes)
Next c
End Sub
=====================================
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top