![]() |
Selecting and merging range within numerous rows
I'm trying to write a code that merges cells from column B to L within
that row (i.e. merge B21:L21 all the way to B1120:L1120). My code merges colums BI to BN through all rows (one monster cell). I'm assuming a For-Next loop is the way to go but am certainly having trouble getting the range called correctly. Dim i As Integer For i = 20 To 1120 Range("Bi:Li").Select With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .ShrinkToFit = False .MergeCells = True End With Next i End Sub I'd greatly appreciate any help. Cheers, Ty |
Selecting and merging range within numerous rows
Dim i As Long
For i = 20 To 1120 Range("B" & i & ":L" & i).Merge Next i But even better is to get them all at once. Range("b20:b1120").Merge across:=True Ty wrote: I'm trying to write a code that merges cells from column B to L within that row (i.e. merge B21:L21 all the way to B1120:L1120). My code merges colums BI to BN through all rows (one monster cell). I'm assuming a For-Next loop is the way to go but am certainly having trouble getting the range called correctly. Dim i As Integer For i = 20 To 1120 Range("Bi:Li").Select With Selection .HorizontalAlignment = xlGeneral .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .ShrinkToFit = False .MergeCells = True End With Next i End Sub I'd greatly appreciate any help. Cheers, Ty -- Dave Peterson |
All times are GMT +1. The time now is 12:08 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com