Excel merge cells
Solved
mike
-
Raph -
Raph -
Hello everyone, I have a cell where a word is written (in Excel), and below it a cell where another word is written. I would like to merge the two cells, but when I merge them, Excel informs me that only the value in the top left corner will be kept. How can I merge two cells that each contain a word?
Thank you
Thank you
21 réponses
- 1
- 2
Suivant
Good evening,
put this macro in a module of your workbook
It concatenates with line breaks everything that is contained in the left column of your selection.
It works with any number of rows and columns you want.
It would need to be improved to properly handle gaps.
Best regards.
put this macro in a module of your workbook
Sub eliot() Set vzone = Selection vtxt = vzone.Range("a1").Value For i = 2 To vzone.Rows.Count vtxt = vtxt & Chr(10) & vzone.Cells(i, 1).Value vzone.Cells(i, 1).ClearContents Next vzone.Range("a1").Value = vtxt With vzone .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = True End With vzone.Range("a1").Value = vzone.Range("a1").Value End SubSelect your 4 cells and run it. It concatenates with line breaks everything that is contained in the left column of your selection.
It works with any number of rows and columns you want.
It would need to be improved to properly handle gaps.
Best regards.
- 1
- 2
Suivant
I've been dreaming of this forever ;-)
thank you
How can we adapt this macro to merge 2 columns into a 3rd one?
Because here we are merging 2 rows into the same cell.
So I want A1 and A2 to be merged into A3.
Thank you!