Merging multiple cells with content

AVRAHAMROOS

New Member
Joined
Nov 24, 2016
Messages
21
I haven't been here for a long time but you guys have helped me in the past immensely when I was building an excel based text analysis tool (see https://www.academia.edu/30391368/PDD_Poetic_Devices_Detector_)

I am now busy with something else text based and need more help.

Given a table with several similar texts in each column - one word per cell e.g.

ABCD
1Lo!Lo!
2ThisThisTHISthis
3isisisis
4asas
5thethethethe
6breadbreadfoodbread
7ofofofof
8afflictionafflictionafflictionaffliction,
9whichwhichwhichwhich
10ourourourour
11ancestorsforefathersfathersancestors
12did
13ateateeatate

<tbody>
</tbody>

I need a way to merge certain cells vertically while keeping all text and do this simultaneously for each text version (=column). E.g. How do I merge "bread of affliction" (or "food of affliction") in rows 6-8 for columns A, B, C, D?
Ideally, it should be done by highlighting rows 6-8 and hitting a macro/ button

The end result should look like this:

ABCD
1Lo!Lo!
2ThisThisTHISthis
3isisisis
4asas
5thethethethe
6bread of afflictionbread of afflictionfood of afflictionbread of affliction,
7whichwhichwhichwhich
8ourourourour
9ancestorsforefathersfathersancestors
10did
11ateateeatate

<tbody>
</tbody>

Thanking you in advance,

Avraham
 
At first I tried to run the macro with just a few numbers in the cells. I now changed the numbers to words and this time I get the following error message:

Can't execute code in break mode.
That means your code did not end, it is still running but only temporarily stopped at a breakpoint. Either click the small square icon in the "ribbon" under the menu bar or, alternately, click the Run menu bar item and then click the Reset item in the dropdown menu that appears to fully halt the program.


The highlighted line in the code is indeed <tbody>[TR]
I am not sure what you are doing, but <tbody.[TR] is not VBA code (looks more like HTML tag information to me)... if you actually have that in your code, delete it as that would not be syntactically correct.


Does this help or should I upload the file?
If doing the above doesn't make the code work correctly, then yes, post the workbook to DropBox and let us see exactly what you have.
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
link to file:

lines I try to merge: 2-6

error message: Can't execute code in break mode

highlighted line in the code: <tbody>[TR]
 
Upvote 0
I explained how to handle the Break Mode warning in Message #11.

As to your code, I was right... you have HTML tags within it which are not part of the VBA code structure. Here is how your code should look...
VBA Code:
Sub test1()
  Dim C As Variant
  For Each C In Intersect(ActiveSheet.UsedRange, Selection).Columns
    Cells(Selection(1).Row, C.Column) = Join(Application.Transpose(Intersect(Selection, C)))
  Next
  Selection(1).Offset(1).Resize(Selection.Rows.Count - 1).EntireRow.Delete
End Sub
In the future, when you take code from this forum, copy it from the forum message directly... do not click the Reply button and try to copy it from there as it has the HTML tags that tell the forum message how to display the code.
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

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