Moving Conditional data from column to column, repost

jlbecker67

New Member
Joined
Mar 26, 2002
Messages
8
How can I move certain data from one column to another? Example:
John Doe.....123.....W...........Main.....St
Jane Doe.....987.....Nowhere.....St

As you can see the street name is shifted left because of the absence of the direction designation. How can I do move all the "St"'s in the wrong column to the right one and then move the street name to the right column? Can I have a formula that finds the two letter designations and moves them to the column to the right? And then have one that finds all data with more than two letters (for the street name) and move it to the column to the right?
Thanks for your help. Sorry I am so ignorant.

Jerry
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi Jerry,

This cannot be done with a formula, since a formula cannot insert cells, rows, or columns to a worksheet. It requires a macro (in this case, a fairly simple one). If this is to be completely general, there may be some special cases that you should think about, such as the street naming in Kittredge Colorado where the streets are Avenues name A-Z. So in the street "E Avenue" the E does not stand for East, but is the name of the street. In some areas, the north-east-south-west designator is given last, such as "72nd Ave W". Do you intend to handle this sort of thing?

Anyway, here is a macro that just looks at every cell in column E, and when it finds one empty shifts the cells C and D on that row one cell to the right. Note that it starts with row 2 assuming that there is a header in row 1.

Sub ShiftAddress()
Dim iRow As Long
'start at row 2 because of header in row 1
For iRow = 2 To [a65536].End(xlUp).Row
If IsEmpty(Cells(iRow, 5)) Then
'shift over the cells in columns C and D
Cells(iRow, 3).Insert shift:=xlToRight
End If
Next iRow
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,534
Messages
6,120,084
Members
448,943
Latest member
sharmarick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top