Reputation: 1
I'm looking to merge 3 horizontal cells, but i am doing so in a loop. The code looks something like this:
myrange.Range(cells(3,i), cells(3,i+3)).mergecells = true
This is not working. I'm guessing its because the code is trying to merge 2 cells that are not adjacent to each other. What is the syntax for merging a range of cells using this cell-address type?
Any help would be greatly appreciated! thanks!
Upvotes: 0
Views: 7957
Reputation: 6984
I'm going to assume myrange is a worksheet, as nothing else makes sense as to what it would be.
Sub MergeIt()
Dim MyRange As Worksheet
i = 1
Set MyRange = Sheets("Sheet1")
With MyRange
.Range(.Cells(3, i), .Cells(3, i + 3)).Merge
End With
End Sub
Upvotes: 1