I'm trying to merge cells in excel that are in the same row into 1 cell and then shift the remaining cells to the left.
Example:
Content | Sample | More | More2
So I want to merge "Content" and "Sample" and shift "More" and "More2" cells to the left so the result would be.
Content Sample | More | More2
I found a code that merges the 2 columns but it merges the 2 columns into 1 but it still takes up the second columns. So I have to "Unmerge" and delete the second column and shift "More" and "More2" to the left.
Heres the code that I have:
Sub MergeOneCell()
'Updateby20140128
Dim Rng As Range
Dim WorkRng As Range
Dim Sigh As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Sigh = Application.InputBox("Symbol merge", xTitleId, ",", Type:=2)
xOut = ""
Application.DisplayAlerts = False
For Each Rng In WorkRng
xOut = xOut & Rng.Value & Sigh
Next
With WorkRng
.Merge
.Value = VBA.Left(xOut, VBA.Len(xOut) - 1)
End With
Application.DisplayAlerts = True
End Sub
Any help would be greatly appreciated. I have a ton of data to process and being able to make this happen would save me hours. I just haven't found any solution so far.