Loop for merging cells

iink

New Member
Joined
Jun 20, 2011
Messages
9
Hello,

I have a list of cells that I need to merge

B27:E27 to B150:E150.

Using:

Range("B27:E27").select
selection.merge
Range("B28:E28").select
selection.merge
etc... down to
Range("B150:E150").select
selection.merge

I can merge the cells, however, this is quite lengthy and irritating to type out. I was wondering if there is a simple loop that I can use to run through each individual range and combine them. The cells that I will be merging have repeat data so I just need it to run through the range and automatically proceed through the warning statement. here is a picture of the statement I would like it to proceed through: http://i.imgur.com/sBe2h.jpg if it is possible.

Any help would be greatly appreciated. Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Maybe like this

Code:
For i = 27 To 150
    Range("B" & i).Resize(, 4).Merge
Next i
 
Upvote 0
This Seems to work...

Code:
Sub Macro1()
    With Range("B27:E27")
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = True
        .Select
    End With
    Selection.AutoFill Destination:=Range("B27:E150")
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,152
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top