Hello!
I have created this macro that will merge and center. This macro does work, but merges and centers the entire row even when the cell is blank.
I would like the merge and center to process to stop at the last used cell in row 3.
Sub merge()
ncolumns = Sheets("Week to Week").Cells(4, Columns.Count).End(xlToLeft).Column
Dim RgToMerge As Range
For i = 3 To ActiveSheet.Cells(Rows.Count, 3).End(xlToLeft).Row Step 2
Set RgToMerge = Range(Cells(3, i), Cells(3, i + 1))
With RgToMerge
.merge
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlCenter
End With
Next i
End Sub
Thank You for any assistance!
I have created this macro that will merge and center. This macro does work, but merges and centers the entire row even when the cell is blank.
I would like the merge and center to process to stop at the last used cell in row 3.
Sub merge()
ncolumns = Sheets("Week to Week").Cells(4, Columns.Count).End(xlToLeft).Column
Dim RgToMerge As Range
For i = 3 To ActiveSheet.Cells(Rows.Count, 3).End(xlToLeft).Row Step 2
Set RgToMerge = Range(Cells(3, i), Cells(3, i + 1))
With RgToMerge
.merge
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlCenter
End With
Next i
End Sub
Thank You for any assistance!