Reputation: 7
Can anyone explain to me why this wont work?
Worksheets("Print_page").Range("2:2,2:7").Merge
Run-time error '1004':
Application-defined or object-defined error
I am trying to merge columns B:F on row 2 and I can't figure it out. Thanks
Upvotes: 0
Views: 73
Reputation: 49998
Seems like you're confusing Range
and Cells
syntax, though all you need is:
Worksheets("Print_page").Range("B2:F2").Merge
If you want to use Cells
:
With Worksheets("Print_page")
.Range(.Cells(2, 2), .Cells(2, 7)).Merge
End With
Upvotes: 1
Reputation: 7567
Sub test()
Range("2:3").Merge '<~~ row merge row 2, 3
Range("b:c").Merge '<~~ column merge b,c
Cells.UnMerge '<~~ cells unmerge
Range("b2:f2").Merge '<~ specific range merge
End Sub
Upvotes: 1