Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Split address in 1 cell into 4

I have a extract from the web that puts the address field all in one and I
need to split this by street address then city state and zip into the next 3
columns. My data looks like this when extracted. There is a Square for the
implied enter after the end of the street address

1107 Hendrick Dr Suite B
Carbondale, CO, 81623

Is there code that could be used to split this from say column F into F, G,
H and I?

Thank you
Holly

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Split address in 1 cell into 4

Assuming the little square is CHAR(10), we will first replace the little
square with a comma and then use Text To Columns. Pull-down;

Edit Replace

1. click in the find what box
2. while holding down the ALT key, touch 010 on the numeric keypad
3. click in the replace with box and enter a comma

Now that we have removed all the squares and replaced them with commas,
click on the column and pull-down:

Data Text to columns Delimited and use the comma as the delimiter.
--
Gary''s Student - gsnu200804


"TXDalessandros" wrote:

I have a extract from the web that puts the address field all in one and I
need to split this by street address then city state and zip into the next 3
columns. My data looks like this when extracted. There is a Square for the
implied enter after the end of the street address

1107 Hendrick Dr Suite B
Carbondale, CO, 81623

Is there code that could be used to split this from say column F into F, G,
H and I?

Thank you
Holly

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Split address in 1 cell into 4

This macro should do what you want (set the data start row and data column
in the indicated Const statements)...

Sub SeparateAddressParts()
Const DataStartRow As Long = 2
Const DataStartCol As String = "F"
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim CellValue As String
Dim Parts() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, DataStartCol).End(xlUp).Row
For X = DataStartRow To LastRow
CellValue = .Cells(X, DataStartCol).Value
If Len(Trim(CellValue)) 0 Then
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)
Parts = Split(CellValue, vbLf)
With .Cells(X, DataStartCol)
.Value = Parts(0)
Parts = Split(Parts(1), ",")
For Z = 0 To 2
.Offset(0, Z + 1) = Trim(Parts(Z))
Next
End With
End If
Next
End With
End Sub

--
Rick (MVP - Excel)


"TXDalessandros" wrote in message
...
I have a extract from the web that puts the address field all in one and I
need to split this by street address then city state and zip into the next
3
columns. My data looks like this when extracted. There is a Square for
the
implied enter after the end of the street address

1107 Hendrick Dr Suite B
Carbondale, CO, 81623

Is there code that could be used to split this from say column F into F,
G,
H and I?

Thank you
Holly


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Split address in 1 cell into 4

Pass it twice through DtaText to Columns

Once with delimiter of CTRL + j to split into F & G

Then again on G with delimiter of comma to split into G, H & I

Record a macro whilst doing this.


Gord Dibben MS Excel MVP

On Thu, 11 Sep 2008 08:46:04 -0700, TXDalessandros
wrote:

I have a extract from the web that puts the address field all in one and I
need to split this by street address then city state and zip into the next 3
columns. My data looks like this when extracted. There is a Square for the
implied enter after the end of the street address

1107 Hendrick Dr Suite B
Carbondale, CO, 81623

Is there code that could be used to split this from say column F into F, G,
H and I?

Thank you
Holly


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Split address in 1 cell into 4

I am getting a compile erro on this
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)

"Rick Rothstein" wrote:

This macro should do what you want (set the data start row and data column
in the indicated Const statements)...

Sub SeparateAddressParts()
Const DataStartRow As Long = 2
Const DataStartCol As String = "F"
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim CellValue As String
Dim Parts() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, DataStartCol).End(xlUp).Row
For X = DataStartRow To LastRow
CellValue = .Cells(X, DataStartCol).Value
If Len(Trim(CellValue)) 0 Then
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)
Parts = Split(CellValue, vbLf)
With .Cells(X, DataStartCol)
.Value = Parts(0)
Parts = Split(Parts(1), ",")
For Z = 0 To 2
.Offset(0, Z + 1) = Trim(Parts(Z))
Next
End With
End If
Next
End With
End Sub

--
Rick (MVP - Excel)


"TXDalessandros" wrote in message
...
I have a extract from the web that puts the address field all in one and I
need to split this by street address then city state and zip into the next
3
columns. My data looks like this when extracted. There is a Square for
the
implied enter after the end of the street address

1107 Hendrick Dr Suite B
Carbondale, CO, 81623

Is there code that could be used to split this from say column F into F,
G,
H and I?

Thank you
Holly





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Split address in 1 cell into 4

What version of Excel are you using?

--
Rick (MVP - Excel)


"TXDalessandros" wrote in message
...
I am getting a compile erro on this
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)

"Rick Rothstein" wrote:

This macro should do what you want (set the data start row and data
column
in the indicated Const statements)...

Sub SeparateAddressParts()
Const DataStartRow As Long = 2
Const DataStartCol As String = "F"
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim CellValue As String
Dim Parts() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, DataStartCol).End(xlUp).Row
For X = DataStartRow To LastRow
CellValue = .Cells(X, DataStartCol).Value
If Len(Trim(CellValue)) 0 Then
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)
Parts = Split(CellValue, vbLf)
With .Cells(X, DataStartCol)
.Value = Parts(0)
Parts = Split(Parts(1), ",")
For Z = 0 To 2
.Offset(0, Z + 1) = Trim(Parts(Z))
Next
End With
End If
Next
End With
End Sub

--
Rick (MVP - Excel)


"TXDalessandros" wrote in
message
...
I have a extract from the web that puts the address field all in one and
I
need to split this by street address then city state and zip into the
next
3
columns. My data looks like this when extracted. There is a Square
for
the
implied enter after the end of the street address

1107 Hendrick Dr Suite B
Carbondale, CO, 81623

Is there code that could be used to split this from say column F into
F,
G,
H and I?

Thank you
Holly




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Split address in 1 cell into 4

MS office std pkg 2003 sp

"Rick Rothstein" wrote:

What version of Excel are you using?

--
Rick (MVP - Excel)


"TXDalessandros" wrote in message
...
I am getting a compile erro on this
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)

"Rick Rothstein" wrote:

This macro should do what you want (set the data start row and data
column
in the indicated Const statements)...

Sub SeparateAddressParts()
Const DataStartRow As Long = 2
Const DataStartCol As String = "F"
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim CellValue As String
Dim Parts() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, DataStartCol).End(xlUp).Row
For X = DataStartRow To LastRow
CellValue = .Cells(X, DataStartCol).Value
If Len(Trim(CellValue)) 0 Then
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)
Parts = Split(CellValue, vbLf)
With .Cells(X, DataStartCol)
.Value = Parts(0)
Parts = Split(Parts(1), ",")
For Z = 0 To 2
.Offset(0, Z + 1) = Trim(Parts(Z))
Next
End With
End If
Next
End With
End Sub

--
Rick (MVP - Excel)


"TXDalessandros" wrote in
message
...
I have a extract from the web that puts the address field all in one and
I
need to split this by street address then city state and zip into the
next
3
columns. My data looks like this when extracted. There is a Square
for
the
implied enter after the end of the street address

1107 Hendrick Dr Suite B
Carbondale, CO, 81623

Is there code that could be used to split this from say column F into
F,
G,
H and I?

Thank you
Holly





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Split address in 1 cell into 4

Okay, that line should work fine in your version of Excel. I see in my
newsreader that the line of code, which is a single line of code, was broken
up into two lines. If your newsreader did that also, and if you simply
copied the code as posted, then you would get the error message you
indicated. The line in question is this one...

CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)

The vbLf on the line all by itself should really be located at the end of
the longer line above it. If you do that, does the error message go away?

--
Rick (MVP - Excel)


"TXDalessandros" wrote in message
...
MS office std pkg 2003 sp

"Rick Rothstein" wrote:

What version of Excel are you using?

--
Rick (MVP - Excel)


"TXDalessandros" wrote in
message
...
I am getting a compile erro on this
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf & vbLf,
vbLf)

"Rick Rothstein" wrote:

This macro should do what you want (set the data start row and data
column
in the indicated Const statements)...

Sub SeparateAddressParts()
Const DataStartRow As Long = 2
Const DataStartCol As String = "F"
Dim X As Long
Dim Z As Long
Dim LastRow As Long
Dim CellValue As String
Dim Parts() As String
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, DataStartCol).End(xlUp).Row
For X = DataStartRow To LastRow
CellValue = .Cells(X, DataStartCol).Value
If Len(Trim(CellValue)) 0 Then
CellValue = Replace(Replace(CellValue, vbCr, vbLf), vbLf &
vbLf,
vbLf)
Parts = Split(CellValue, vbLf)
With .Cells(X, DataStartCol)
.Value = Parts(0)
Parts = Split(Parts(1), ",")
For Z = 0 To 2
.Offset(0, Z + 1) = Trim(Parts(Z))
Next
End With
End If
Next
End With
End Sub

--
Rick (MVP - Excel)


"TXDalessandros" wrote in
message
...
I have a extract from the web that puts the address field all in one
and
I
need to split this by street address then city state and zip into
the
next
3
columns. My data looks like this when extracted. There is a Square
for
the
implied enter after the end of the street address

1107 Hendrick Dr Suite B
Carbondale, CO, 81623

Is there code that could be used to split this from say column F
into
F,
G,
H and I?

Thank you
Holly






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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
split a cell diagonally in excell - a calendar -2 dates in 1 cell Vicki Excel Discussion (Misc queries) 1 October 31st 06 02:40 PM
how to split address blocks across multiple cells JoannaF Excel Worksheet Functions 13 May 2nd 06 12:19 PM
Split Address Correction Carleton New Users to Excel 1 April 11th 06 09:14 AM
Split email address into seperat columns mg_sv_r Excel Worksheet Functions 1 January 9th 06 11:56 AM


All times are GMT +1. The time now is 07:08 AM.

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

About Us

"It's about Microsoft Excel"