Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ty Ty is offline
external usenet poster
 
Posts: 3
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting rows within a range JCG Excel Worksheet Functions 5 July 21st 09 02:57 PM
Excel - merging numerous files drumbumuk Excel Discussion (Misc queries) 7 August 12th 08 04:41 PM
Merge data from numerous rows in one column [email protected] Excel Discussion (Misc queries) 1 October 18th 07 11:10 PM
selecting range of cells - variable # of rows [email protected] Excel Programming 6 April 15th 05 02:10 PM
Selecting a range composed of current region + 2 rows Bruce Roberson[_5_] Excel Programming 2 October 27th 04 03:00 PM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"