moving text from cell a to cell B and cell c

2k05gt

Board Regular
Joined
Sep 1, 2006
Messages
157
I have a Cell with some text the looks like this

A1 = Marshal of Omaha, NE
A2 = Baker of Lincolin, NE
A3 = Steil of Washington, DC
A4 = Favio of San Juan, PR

I want to split the cell data like this.

A1 = Marshal of B1 = Omaha C1 = NE
A2 = Baker of B2 = Lincolin C2 = NE
A3 = Steil of B3 = Washington C3 = DC
A4 = Favio of B4 = San Juan C4 = PR


How do I build this Maco? the word "of" and the comma "," are constents

I have tired the following

=IF(ISNUMBER(FIND("of",a1,1)),"of","")

=RIGHT(A1,LEN(A1)-FIND(", ",A1))

Also tried doing a VBA script
Sub Separate()
Dim City As String
Dim State As String
Dim Pos As Long

Pos = InStr(1, ActiveCell.Value, " ")
City = Mid(ActiveCell.Value, 1, Pos - 1)
State = Mid(ActiveCell.Value, Pos + 1)
ActiveCell.Value = City
ActiveCell.Offset(0, 1).Value = State
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Maybe like this
Excel Workbook
ABCD
1Marshal of Omaha, NEMarshal ofOmahaNE
2Baker of Lincolin, NEBaker ofLincolinNE
3Steil of Washington, DCSteil ofWashingtonDC
Sheet2
 
Upvote 0
or via VBA
Code:
Sub breakMe()
Dim c As Range
For Each c In Range("A1:A10")
If c <> "" Then
    With c
       .Offset(, 2) = Right(c, 2)
       .Offset(, 1) = Mid(c, WorksheetFunction.Find("of", c) + 3, (WorksheetFunction.Find(",", c) - (WorksheetFunction.Find("of", c) + 3)))
       .Offset(0, 0) = Left(c, WorksheetFunction.Find("of", c) + 1)
    End With
End If
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,822
Members
452,946
Latest member
JoseDavid

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