Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default howto replace the order of adress ?

On Thu, 13 Dec 2007 07:05:00 -0800, ???? wrote:

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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Try again - adress from a range to combobox alvin Kuiper Excel Programming 3 February 23rd 06 10:07 PM
getting the adress on the last row alvin Kuiper Excel Programming 4 February 11th 06 04:00 PM
Find value and adress acces[_6_] Excel Programming 1 January 23rd 04 12:42 PM
HOWTO Replace from Row Don Guillett[_4_] Excel Programming 9 August 24th 03 03:14 PM
HOWTO Replace from Row SolaSig AB Excel Programming 0 August 22nd 03 12:12 PM


All times are GMT +1. The time now is 07:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"