Merge Every 9 cells

TenDollarTypo

New Member
Joined
Dec 9, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Sub SelectEvery9Rows()

Dim MyRange As Range
Dim RowSelect As Range
Dim i As Integer
Set MyRange = Selection
Set RowSelect = MyRange.Rows(9)

For i = 9 To MyRange.Rows.Count Step 9

Set RowSelect = Union(RowSelect, MyRange.Rows(i))

Next i
Application.Goto RowSelect

With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel 0
.ShrinkTorit = False
.ReadingOrder = xlContext
.MErgeCells = False

End With
Selection.Merge
End Sub

Keep getting an error is there something wrong with the code?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I can see 2 errors in this part, the first line is missing the =, the second has a spelling error.
.IndentLevel 0
.ShrinkTorit = False
There are a couple of things in your code that don't make sense but I think that this corrected code will do what you want.
VBA Code:
Sub MergeEvery9Rows()

Dim rng As Range, i As Long

For i = 1 To Selection.Rows.Count Step 9
    
    With Selection(i).Resize(9)
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
        .Merge
    End With
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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