|  

» Merge cells without loosing values using VBA in Microsoft Excel

Question:
The cells from column A and B are to be merged without losing the values from column B


Answer:
Insert the following code in the appropriate modules.





Place the code below into the standard module


Sub Connects()
Dim intRow As Integer
Dim txt As String
intRow = 1
Do Until IsEmpty(Cells(intRow, 1))
Cells(intRow, 1) = Cells(intRow, 1) & " - " & Cells(intRow, 2)
Cells(intRow, 2).ClearContents
Range(Cells(intRow, 1), Cells(intRow, 2)).Merge
intRow = intRow + 1
Loop
Columns(1).AutoFit
End Sub



Rate This Tip
12 34 5
Rating: 2.76     Views: 21468
No comments have been submitted.
Click here to post comment
For Registered Users
Name
Comment Title
Comments