VBA Merging cells to form 1 Address cell

Lres81715

Board Regular
Joined
Aug 26, 2015
Messages
147
I'ts gotta be an easy request but I can't seem to figure it out

I have a massive distribution list that I need to merge the multiple cells below the main line of information into one address cell. So the contents appear as one list. The simplified version of the the request appears like this

NameCompanyAddressGoal
A, NancyABC Company1234 Main St1234 Main St Bakersfield, CA 93311
Bakersfield, CA 93311
A, JDABC Company12345 Parkplace12345 Parkplace Kirkland, WA 98033
Kirkland, WA 98033
A, JoeABC Company12345 Pinnacle Dr12345 Pinnacle Dr POBox 3076 McLean, VA 22102
POBox 3076
McLean, VA 22102
A, StephanieABC Company12345 Main St, 2nd Floor12345 Main St, 2nd Floor POBOX 2301 West Des Moines, IA 50328
POBOX 2301
West Des Moines, IA 50328
A, SteveABC Company123 Aston Ave Ste 123123 Aston Ave Ste 123 Carlsbad, CA 92008
Carlsbad, CA 92008
A, VickeeABC Company12345 Main St, 2nd Floor12345 Main St, 2nd Floor Des Moines, IA 50328
Des Moines, IA 50328
A, SarahABC Company12345 W Wabash12345 W Wabash POBox 2803-01G Springfield, IL 62711 UNITED STATES
POBox 2803-01G
Springfield, IL 62711
UNITED STATES
A, JamesABC Company12345 Harrison St Fl 2ND12345 Harrison St Fl 2ND Oakland, CA 94612
Oakland, CA 94612

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>


So cell C2 has the rest of the address filling in one row below and in the case of A, Sarah's company, multiple rows below it. the Goal is to combine all the information into one cell like in the last column. any idea how to do this?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try this on a copy of your worksheet.
Code:
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "C").End(xlUp).Row
For r = lr To 3 Step -1
    If Range("B" & r).Value = "" Then
        Range("C" & r - 1).Value = Range("C" & r - 1).Value & " " & Range("C" & r).Value
        Rows(r).Delete
    End If
Next r
End Sub
 
Last edited:
Upvote 0
Try this on a copy of your worksheet.
Code:
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "C").End(xlUp).Row
For r = lr To 3 Step -1
    If Range("B" & r).Value = "" Then
        Range("C" & r - 1).Value = Range("C" & r - 1).Value & " " & Range("C" & r).Value
        Rows(r).Delete
    End If
Next r
End Sub

Yup! that was it. Forgot about going backwards in a step count. Thanks Michael
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,085
Members
449,206
Latest member
ralemanygarcia

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