Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Split last word into new cell

I have a bunch of addresses where the last word of each address needs to be
split. Eg. edgeware road london. I would like edgeware road to stay in its
cell and london to be removed and placed in the cell to the right.

A formula or vba solution would be appreciated.
--
Thanks in advance,
MarkN
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Split last word into new cell

Mark how do yuo cope with 'North Shields' or 'Milton Keynes'?

Here is a VBA solution as a function.

Put a 1 in as the town and 0 or blank for the road:

Function split_address(s As String, Optional item As Integer = 0) As String
Dim pos As Integer
Dim s_town As String, s_road As String

s = Trim(s) ' remove spaces leading and trailing spaces
pos = InStr(1, StrReverse(s), " ")

s_town = Right(s, pos - 1)
s_road = Left(s, Len(s) - pos + 1)
split_address = IIf(item = 1, s_town, s_road)
End Function


--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"MarkN" wrote:

I have a bunch of addresses where the last word of each address needs to be
split. Eg. edgeware road london. I would like edgeware road to stay in its
cell and london to be removed and placed in the cell to the right.

A formula or vba solution would be appreciated.
--
Thanks in advance,
MarkN

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
Trying to split a cell in Excel 2003, just like in Word Tables Kjandar Excel Discussion (Misc queries) 3 March 21st 12 07:36 PM
Split up word in cell spartacus13210 Excel Programming 8 August 17th 07 03:13 AM
Split cell without breaking word? Doug Benjamin Excel Discussion (Misc queries) 8 April 13th 06 01:23 AM
Split cell as we do in table in word PK Baranwal New Users to Excel 2 March 9th 06 06:55 AM
Split Long Text Cell into Two Shorter Cells Without Splitting Word Naomi T Excel Discussion (Misc queries) 1 July 7th 05 06:49 AM


All times are GMT +1. The time now is 01:01 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"