Gingertrees
11-15-2009, 05:24 AM
Hello,
I hope this is an easy fix for someone - I want to do a repeated merge for the range I select.
So if I select D1:L12, I want to merge
D1:L1
D2:L2
D3:L3 etc down to D12:L12
Here's what I came up with that merges nothing.
Am I on the right track at least?
Sub MergeRows()
Dim MergeRange As Range
Dim Cell1 As Object
Dim CellLast As Object
With ActiveSheet
On Error Resume Next
Cell1 = InputBox("1st cell?")
CellLast = InputBox("Last cell?")
MergeRange = Range(Cell1, CellLast)
For Each Row In MergeRange.Rows
Range(Cells(MergeRange.Row, 1), Cells(MergeRange.Row, 9)).Merge
Next Row
End With
End Sub
I hope this is an easy fix for someone - I want to do a repeated merge for the range I select.
So if I select D1:L12, I want to merge
D1:L1
D2:L2
D3:L3 etc down to D12:L12
Here's what I came up with that merges nothing.
Am I on the right track at least?
Sub MergeRows()
Dim MergeRange As Range
Dim Cell1 As Object
Dim CellLast As Object
With ActiveSheet
On Error Resume Next
Cell1 = InputBox("1st cell?")
CellLast = InputBox("Last cell?")
MergeRange = Range(Cell1, CellLast)
For Each Row In MergeRange.Rows
Range(Cells(MergeRange.Row, 1), Cells(MergeRange.Row, 9)).Merge
Next Row
End With
End Sub