Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Is this possible: Parse a Cell


hello

i have a cell with addresses and i want to split the address into hous
number and street name

for example cell C1: 123 Springfield Lane

split to
C1: 123
D1: Springfield Lane


thank

--
narutar
-----------------------------------------------------------------------
narutard's Profile: http://www.excelforum.com/member.php...fo&userid=2511
View this thread: http://www.excelforum.com/showthread.php?threadid=46825

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Is this possible: Parse a Cell

There are a number of ways to achieve this. The simplist way would be to
place your cursor in the cell which contains the full address and run the
following macro:

Public Sub parseaddress()
Dim thevalue$
Dim thehouseno$
x = ActiveCell.Row
y = ActiveCell.Column
thevalue = ActiveCell.Value
thehouseno = Left(ActiveCell.Value, InStr(1, ActiveCell.Value, " "))
Range(Cells(x, y + 1), Cells(x, y + 1)).Value = thehouseno
Range(Cells(x, y + 2), Cells(x, y + 2)).Value = Right(ActiveCell.Value,
Len(ActiveCell.Value) - Len(thehouseno))

End Sub

This will parse the value in the active cell and split the first word into
the next column and the rest of the entry into the 2nd column. There are
obvious limitiations to this and you may want to adjust it to specifically
look for digits instead.

The second problem with this macro is that it only works on a single cell at
a time. If you have a large no. of cells that you wish to change you may
wish to make them into a named range and then enclose the above within a
loop:-

Public Sub parseaddress()
Dim thevalue$
Dim thehouseno$

For Each c In Range("myRangeName")
c.Select
x = ActiveCell.Row
y = ActiveCell.Column
thevalue = ActiveCell.Value
thehouseno = Left(ActiveCell.Value, InStr(1, ActiveCell.Value, " "))
Range(Cells(x, y + 1), Cells(x, y + 1)).Value = thehouseno
Range(Cells(x, y + 2), Cells(x, y + 2)).Value = Right(ActiveCell.Value,
Len(ActiveCell.Value) - Len(thehouseno))
Next c
End Sub

Hope this gives you some pointers...


June


"narutard" wrote in
message ...

hello

i have a cell with addresses and i want to split the address into house
number and street name

for example cell C1: 123 Springfield Lane

split to
C1: 123
D1: Springfield Lane


thanks


--
narutard
------------------------------------------------------------------------
narutard's Profile:

http://www.excelforum.com/member.php...o&userid=25111
View this thread: http://www.excelforum.com/showthread...hreadid=468255



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default Is this possible: Parse a Cell

If you don't have exceptions

J2: =LEFT(C2,FIND(" ",C2)-1)
K2: =TRIM(MID(C2,FIND(" ",C2),400))

The VBA is along similar lines you don't need the third operand for MID
and you can use InStr instead of Find.

For a permanent separation and not just a helper column
you could use the SepTerm macro at
http://www.mvps.org/dmcritchie/excel/join.htm#septerm
after creating a new column to the right.

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"narutard" wrote in message
...

hello

i have a cell with addresses and i want to split the address into house
number and street name

for example cell C1: 123 Springfield Lane

split to
C1: 123
D1: Springfield Lane


thanks


--
narutard
------------------------------------------------------------------------
narutard's Profile: http://www.excelforum.com/member.php...o&userid=25111
View this thread: http://www.excelforum.com/showthread...hreadid=468255



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
help - need to parse a cell confused Excel Worksheet Functions 2 October 30th 09 07:22 PM
Parse cell contents ? Fullam Excel Discussion (Misc queries) 4 May 3rd 06 06:14 PM
Parse contents of cell Portuga Excel Discussion (Misc queries) 4 March 28th 06 03:44 PM
Parse ST-ZIP Cell (15,427 times...) jawdawson Excel Discussion (Misc queries) 5 January 20th 06 06:15 PM
Parse cell reference Bob Phillips[_5_] Excel Programming 0 August 5th 03 08:05 PM


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