Excel merge cells

Solved
mike -  
 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

21 réponses

  • 1
  • 2
JvDo Posted messages 1924 Registration date   Status Membre Last intervention   859
 
Good evening,

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 Sub
Select 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.
18
alpheratz
 
I tested this macro, it's working perfectly
I've been dreaming of this forever ;-)
thank you
0
Lo!
 
Hello,

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!
0
  • 1
  • 2