Reputation: 79
I'm trying to create simple macro (since I have some repetitive work) that would merge (but not merge in excel way of joining two cells, but moving value of rest of cells to the first one) values. I thought I could loop through selection, and join with & symbol second cell to first, then third to first and so. So I have something like this:
Sub scal()
Dim rng As Range
Dim cell As Range
Set rng = Selection
For Each cell In rng
'code here
Next cell
End Sub
This way I can maniopulate each cell, but how can I do merging (once again not merging-merging like making two cells one, but moving value of one to other)?
Upvotes: 0
Views: 46
Reputation: 53137
Something like this?
Sub scal()
Dim rng As Range
Dim cell As Range
Dim v As Variant
Set rng = Selection
For Each cell In rng
v = v & cell.Value
Next cell
rng.ClearContents
rng.Cells(1, 1) = v
End Sub
Upvotes: 1