ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Merge cells using macro (https://www.excelbanter.com/excel-programming/273846-re-merge-cells-using-macro.html)

Tom Ogilvy

Merge cells using macro
 
NumRows = 1
NumCols = 2
With Range("A4").Resize(NumRows,NumCols)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With


Regards,
Tom Ogilvy

"Amy" wrote in message
...
I am trying to merge some cells using a macro. I'm
successful when using the command:

Range("A4:A5").select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = True
End With

However, the range of cells I want to merge is different
everytime, so I would like the macro to be able to count
the number of cells to be merged (some command that allows
definig a range using relative cell reference).

Thanks,

Amy





All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com