Thread: Move text
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Move text

On Wed, 21 May 2008 18:36:21 -0700, pattlee
wrote:

Hi Ron read your message but fail to see where the code is .. Am I missing
something? Patt

"Ron Rosenfeld" wrote:

On Wed, 21 May 2008 17:44:01 -0700, pattlee
wrote:

Data is in Column G As City,State,Zip Need a Macro that will move City to Col
E and the State to Col F. and leave the Zip in the Col G.... Can't seem to
get the ofset parameter correct..or get rid of the comma between City,State
Would appreciate any help Regards Patt


Here's one way that might work.

Note that I hard coded the range to check in Col G. There are many ways that
this could be set up, depending on how your data is organized. But this should
get you started.
--ron


Oops:

===========================
Option Explicit
Sub ParseCityStateZip()
Dim c As Range
Dim sTemp
For Each c In Range("G1:G100")
With c
If Len(.Text) - Len(Replace(.Text, ",", "")) = 2 Then
sTemp = Split(.Text, ",")
.Offset(0, -2).Value = sTemp(0)
.Offset(0, -1).Value = sTemp(1)
.NumberFormat = "@"
.Value = sTemp(2)
End If
End With
Next c
End Sub
============================
--ron