Excel offers the ability to summarize, cells. About the "Format - Cells - Alignment - Merge Cells", you can combine two cells into one unit. What do you do when two cells are located in content that does not want to lose you? Insert VBA to solve the task. The example in the following figure shows a short list of names. You want to summarize the contents of the two columns A and B in the first column A and then combine the two cells in columns A and B into one cell. The following macro does the job:
Dim row As Integer
Code:
Line = 1
While Not (IsEmpty (Cells (row, 1)))
Cells (row, 1) = Cells (row, 1) & "" & Cells (row, 2)
Cells (row 2). ClearContents
Range (Cells (row, 1), Cells (row, 2)). Merge
Row = row + 1
Applicable
Columns (1). AutoFit
End Sub
The macro loops through the lines from line 1 to column A appears in an empty content. For every non-empty content, the content of A and B (separated by a space) concatenated. Subsequently, the two cells A and B are connected to a cell.
Bookmarks