ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Splitting up address (https://www.excelbanter.com/excel-programming/364738-splitting-up-address.html)

Neal

Splitting up address
 
How would I write a macro that would split up an addrss by spaces? Lets say
the address is 1364 W elm street apt #4? I am new to coding so I dont know
where to start. Also I need the macro to run down the list until there is no
address to move.
Any help would be greatly appreciated, thanks Neal.

[email protected]

Splitting up address
 
I suggest you start by recording a macro of you using the text to
columns function and using a space as your delimitor.

From there you can see the code and play with it from there.


Neal wrote:
How would I write a macro that would split up an addrss by spaces? Lets say
the address is 1364 W elm street apt #4? I am new to coding so I dont know
where to start. Also I need the macro to run down the list until there is no
address to move.
Any help would be greatly appreciated, thanks Neal.



excelent

Splitting up address
 
or try this 1 i got from mr. bak

Sub test()
Dim rCell As Range
For Each rCell In Selection
rCell(1, 2).Resize(, 6) = Split(rCell, " ")
Next
End Sub


excelent

Splitting up address
 
remember select ur adress cells, - and run kode

" skrev:

I suggest you start by recording a macro of you using the text to
columns function and using a space as your delimitor.

From there you can see the code and play with it from there.


Neal wrote:
How would I write a macro that would split up an addrss by spaces? Lets say
the address is 1364 W elm street apt #4? I am new to coding so I dont know
where to start. Also I need the macro to run down the list until there is no
address to move.
Any help would be greatly appreciated, thanks Neal.




Neal

Splitting up address
 
Thank you it works great.

"excelent" wrote:

remember select ur adress cells, - and run kode

" skrev:

I suggest you start by recording a macro of you using the text to
columns function and using a space as your delimitor.

From there you can see the code and play with it from there.


Neal wrote:
How would I write a macro that would split up an addrss by spaces? Lets say
the address is 1364 W elm street apt #4? I am new to coding so I dont know
where to start. Also I need the macro to run down the list until there is no
address to move.
Any help would be greatly appreciated, thanks Neal.




Neal

Splitting up address
 
How do I avoid getting a null value in the remainding cells. Not every
address will have 6 cells to populate?Is there a way to write it out to stop
after it hits a blank spot?

"excelent" wrote:

remember select ur adress cells, - and run kode

" skrev:

I suggest you start by recording a macro of you using the text to
columns function and using a space as your delimitor.

From there you can see the code and play with it from there.


Neal wrote:
How would I write a macro that would split up an addrss by spaces? Lets say
the address is 1364 W elm street apt #4? I am new to coding so I dont know
where to start. Also I need the macro to run down the list until there is no
address to move.
Any help would be greatly appreciated, thanks Neal.




excelent

Splitting up address
 
Sub test()
Dim c, cCount
Dim rCell As Range
For Each rCell In Selection
For c = 1 To Len(rCell)
If Mid(rCell, c, 1) = " " Then cCount = cCount + 1
Next
rCell(1, 2).Resize(, cCount + 1) = Split(rCell, " "): cCount = 0
Next
End Sub


Neal

Splitting up address
 
This worked great. I had one question about assigning a range. Would i enter
it under the dim rcell as range, and would it be range("A1").select? Thanks
for the help.

"excelent" wrote:

Sub test()
Dim c, cCount
Dim rCell As Range
For Each rCell In Selection
For c = 1 To Len(rCell)
If Mid(rCell, c, 1) = " " Then cCount = cCount + 1
Next
rCell(1, 2).Resize(, cCount + 1) = Split(rCell, " "): cCount = 0
Next
End Sub


excelent

Splitting up address
 
U have to select all the cells in a column u want to split, then run kode

Im not sure if that is what u mean

else ask again but keep it simple cus im from Denmark :-)


Neal

Splitting up address
 
Ok, thanks. The code should like this?

Sub test()
range("A1").select
Dim c, cCount
Dim rCell As Range
For Each rCell In Selection
For c = 1 To Len(rCell)
If Mid(rCell, c, 1) = " " Then cCount = cCount + 1
Next
rCell(1, 2).Resize(, cCount + 1) = Split(rCell, " "): cCount = 0
Next
End Sub


"excelent" wrote:

U have to select all the cells in a column u want to split, then run kode

Im not sure if that is what u mean

else ask again but keep it simple cus im from Denmark :-)



All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com