Split Husband and Wife into Two rows from one

Rogeman

New Member
Joined
Sep 23, 2013
Messages
15
I attach Two sample Databases, the originals containing about 500 People, the first contains Husband and Wife (or Other combinations).

I need to print their Individual Names and other details Etc in a letter, as in the second database. So that I can then do an individual mail merge for each person.

Each person needs their own row entry.

How do I single out the appropriate individual Titles, Initials and Forenames from the original rows and then insert them into the database with the remaining details of surname and address? Creating two rows from the original one.

Is there a way in Excel Formulas or VBA to achieve this?



Roger
 

Attachments

  • Sample Data.jpg
    Sample Data.jpg
    160.8 KB · Views: 55

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
This can certainly be done with the help of a VBA.
Could you provide your data in a copy-able format? so that we don't have to type and prepare the scenario ourselves?

I am not good at VBA but there are lot of experts who can come up with an elegant solution.

You can use the below given XL2BB tool link to present your data in a copyable format.
XL2BB Link
 
Upvote 0
snjpverma,
Thanks for your reply, i did not realise how I could upload an excel file, I hope it works ok.

Roger

Original listing
Mr & MrsT & RTerenceRuthSmithHigh StrettLondonSw1
MrJJamesEvansMain StreetLondonSw2
Mr & MrsR & JRogerJenniferJonesold StreetLondonSw3
Mr & MrsJ & AJeffAnneBrownNew StreetLondonSw4
MrsGGaynorGreenLong Lane Short LaneLondonSw5
Mr & MrsD & WDavidWendyBlueQuay streetLondonSw6
MissMPeggyRedHill StreetLondonSw7
MrsKKathrynTellowBack LaneLondonSw8
Mr & MsA & MAdrianMeganCramp & SmithOld RoadLondonSw9
Required Listing
MrTTerenceSmithHigh StrettLondonSw1
MrsRRuthSmithHigh StrettLondonSw1
MrJJamesEvansMain StreetLondonSw2
MrsJAnnEvansMain StreetLondonSw2
MrRRogerJonesold StreetLondonSw3
MrsJJenniferJonesold StreetLondonSw3
MrAAdrianCrampOld RoadLondonSw9
MrsMMeganSmithOld RoadLondonSw9
MrKKenTellowBack LaneLondonSw8
MrsKKathrynTellowBack LaneLondonSw8
MrPPercyRedHill StreetLondonSw7
MissMPeggyRedHill StreetLondonSw7
MrDDavidBlueQuay streetLondonSw6
DrWWendyBlueQuay streetLondonSw6
 
Upvote 0
See if this works for you

VBA Code:
Sub t()
Dim c As Range, spl As Variant
For Each c In Range("A2", Cells(Rows.Count, 1).End(xlUp))
    If InStr(c, "&") > 0 Then
        spl = Split(c, "&")
        Rows(c.Row).Insert
        c.Offset(-1) = Trim(spl(0))
        c = Trim(spl(1))
    End If
    If InStr(c.Offset(, 1), "&") > 0 Then
        spl = Split(c.Offset(, 1), "&")
        c.Offset(-1, 1) = Trim(spl(0))
        c.Offset(, 1) = Trim(spl(1))
        If c.Offset(, 2) <> "" Then
            c.Offset(, 2).Cut c.Offset(-1, 3)
        End If
        c.Offset(, 4).Resize(, 4).Copy c.Offset(-1, 4)
    End If
    If c.Offset(, 2) <> "" Then
        c.Offset(, 2).Cut c.Offset(, 3)
    End If
Next
End Sub
 
Upvote 0
JLGWhiz,

Thanks your macro worked a treat, but my sample I provided only went to column 'H' but my database actualy goes to column 'T'.
Sorry I did not think of that detail.
The only problem I can see is that on each 'couple' when separated the first one does not have any data after column 'H'
I have tried to understand your code but I am not that confident.
What do I need to add to make it include column 'T'?

Thanks again much appreciated

Roger
 
Upvote 0
Change this line
Code:
c.Offset(, 4).Resize(, 4).Copy c.Offset(-1, 4)
To this
Code:
c.Offset(, 4).Resize(, 16).Copy c.Offset(-1, 4)
 
Upvote 0
It is the number of columns from (and including) c offset by 4 columns, in this case c.Offset(, 4) is referring to column E. So it is the number of columns from column E to column T i.e. 16 columns including column E..
 
Upvote 0
MARK858,
Thanks for your explanation.I have now run the macro and it does exactly what
I wanted.
Thanks again to all who have helped.

Roger
 
Upvote 0

Forum statistics

Threads
1,215,606
Messages
6,125,803
Members
449,261
Latest member
Rachel812321

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