#1   Report Post  
Zip Codes
 
Posts: n/a
Default Splitting Cell Data

I have about 900 cells and all of them appear in the following way
A
Town, State, 99999
Town1, State1, 11111

I need to have the zip code (99999 in the example) in one column, and then
town and state in another column so it would look like this
A B
Town, State 99999
Town 1, State 1 11111

I've been experimenting with the RIGHT and LEFT formula-- =RIGHT (A1, 5)
which would give me the zip code. The problem is i can only do this for
individual cells so i would have to do A1, A2, A3 and so on. Is there a way
to write a macro or formula to get all of the cells to transfer over without
having to type A1 over and over?
  #2   Report Post  
JMB
 
Posts: n/a
Default

Easiest way is to select/highlight all of your data in column A. Click on
Data/Text To Columns. Select Fixed Width. You will see a Data Preview
Screen w/vertical lines. These vertical lines will be column breaks. You
can drag them to right/left, remove them by doubleclicking on the line, or
put one in by a single click.

Put breaks in as follows

City, State|,|Zip

Now, after you click next, select the column with the comma in it, and
select the "Do not Import" option. Then click finish.




"Zip Codes" wrote:

I have about 900 cells and all of them appear in the following way
A
Town, State, 99999
Town1, State1, 11111

I need to have the zip code (99999 in the example) in one column, and then
town and state in another column so it would look like this
A B
Town, State 99999
Town 1, State 1 11111

I've been experimenting with the RIGHT and LEFT formula-- =RIGHT (A1, 5)
which would give me the zip code. The problem is i can only do this for
individual cells so i would have to do A1, A2, A3 and so on. Is there a way
to write a macro or formula to get all of the cells to transfer over without
having to type A1 over and over?

  #3   Report Post  
Biff
 
Posts: n/a
Default

Hi!

The problem is i can only do this for individual cells so i would have to
do A1, A2, A3 and so on.


Simply drag copy or, it can be as easy as double clicking the fill handle.

Try this....

Assume your data is in A1:A900 with no empty cells within that range.

In B1 enter this formula:

=RIGHT(A1,5)

In C1 enter this formula:

=SUBSTITUTE(A1,", "&B1,"")

Select both B1 and C1.

Double click the fill handle to copy the formulas down to row 900.

Inspect the results to make sure they're correct. When satisfied select both
columns B and C. Right click within that selected range and click Copy. Then
right click within that range again and select Paste Special ValuesOK.

Now, if you want, you can delete column A and then drag column C over to be
the new column A.

Biff

"Zip Codes" wrote in message
...
I have about 900 cells and all of them appear in the following way
A
Town, State, 99999
Town1, State1, 11111

I need to have the zip code (99999 in the example) in one column, and then
town and state in another column so it would look like this
A B
Town, State 99999
Town 1, State 1 11111

I've been experimenting with the RIGHT and LEFT formula-- =RIGHT (A1, 5)
which would give me the zip code. The problem is i can only do this for
individual cells so i would have to do A1, A2, A3 and so on. Is there a
way
to write a macro or formula to get all of the cells to transfer over
without
having to type A1 over and over?



  #4   Report Post  
Biff
 
Posts: n/a
Default

Hi!

That would only work as long as the

City, State|,|Zip


data to separate is all equal in length and the second comma is in the same
location in every cell. I'm assumming that the real data looks like this:

Columbus, Ohio, 44452
Beaver Falls, Pennsylvania, 15010
Fresno, California, 95488

In which case T to C fixed will not work. Of course, you could use T to C
delimited by comma and end up with 3 columns.

Biff

"JMB" wrote in message
...
Easiest way is to select/highlight all of your data in column A. Click on
Data/Text To Columns. Select Fixed Width. You will see a Data Preview
Screen w/vertical lines. These vertical lines will be column breaks. You
can drag them to right/left, remove them by doubleclicking on the line, or
put one in by a single click.

Put breaks in as follows

City, State|,|Zip

Now, after you click next, select the column with the comma in it, and
select the "Do not Import" option. Then click finish.




"Zip Codes" wrote:

I have about 900 cells and all of them appear in the following way
A
Town, State, 99999
Town1, State1, 11111

I need to have the zip code (99999 in the example) in one column, and
then
town and state in another column so it would look like this
A B
Town, State 99999
Town 1, State 1 11111

I've been experimenting with the RIGHT and LEFT formula-- =RIGHT (A1, 5)
which would give me the zip code. The problem is i can only do this for
individual cells so i would have to do A1, A2, A3 and so on. Is there a
way
to write a macro or formula to get all of the cells to transfer over
without
having to type A1 over and over?



  #5   Report Post  
JMB
 
Posts: n/a
Default

Yeah, I was asleep on that one.


"Biff" wrote:

Hi!

The problem is i can only do this for individual cells so i would have to
do A1, A2, A3 and so on.


Simply drag copy or, it can be as easy as double clicking the fill handle.

Try this....

Assume your data is in A1:A900 with no empty cells within that range.

In B1 enter this formula:

=RIGHT(A1,5)

In C1 enter this formula:

=SUBSTITUTE(A1,", "&B1,"")

Select both B1 and C1.

Double click the fill handle to copy the formulas down to row 900.

Inspect the results to make sure they're correct. When satisfied select both
columns B and C. Right click within that selected range and click Copy. Then
right click within that range again and select Paste Special ValuesOK.

Now, if you want, you can delete column A and then drag column C over to be
the new column A.

Biff

"Zip Codes" wrote in message
...
I have about 900 cells and all of them appear in the following way
A
Town, State, 99999
Town1, State1, 11111

I need to have the zip code (99999 in the example) in one column, and then
town and state in another column so it would look like this
A B
Town, State 99999
Town 1, State 1 11111

I've been experimenting with the RIGHT and LEFT formula-- =RIGHT (A1, 5)
which would give me the zip code. The problem is i can only do this for
individual cells so i would have to do A1, A2, A3 and so on. Is there a
way
to write a macro or formula to get all of the cells to transfer over
without
having to type A1 over and over?






  #6   Report Post  
Bob Cresto
 
Posts: n/a
Default

If they all have a comma separating Town, State, and zip you could use
the Text to Columns under Data to separate the data into 3 columns. Then
use =A1&","&B1 to put the town and state back together in one column.

Bob

Zip Codes wrote:
I have about 900 cells and all of them appear in the following way
A
Town, State, 99999
Town1, State1, 11111

I need to have the zip code (99999 in the example) in one column, and then
town and state in another column so it would look like this
A B
Town, State 99999
Town 1, State 1 11111

I've been experimenting with the RIGHT and LEFT formula-- =RIGHT (A1, 5)
which would give me the zip code. The problem is i can only do this for
individual cells so i would have to do A1, A2, A3 and so on. Is there a way
to write a macro or formula to get all of the cells to transfer over without
having to type A1 over and over?

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
Input cell on Data Table will not work Sarah Bee Excel Discussion (Misc queries) 4 May 26th 05 12:51 AM
how do i reference data in a file with the fname in another cell? jhlrtn Excel Worksheet Functions 1 May 23rd 05 11:11 PM
up to 7 functions? ALex Excel Worksheet Functions 10 April 12th 05 06:42 PM
Import Data into same cell ib_redbeard Excel Discussion (Misc queries) 3 March 1st 05 12:08 PM
Repeat Cell Data Pinky Excel Worksheet Functions 1 January 18th 05 05:38 PM


All times are GMT +1. The time now is 10:29 PM.

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"