ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   programatically merge cells? (https://www.excelbanter.com/excel-programming/320043-programatically-merge-cells.html)

David Bateman

programatically merge cells?
 
I am using Microsoft Excel 2000. How can I write a macro which will
automatically merge every three cells in Row 10. That is merge column a, b,
c, then d, e, f etc.


Thanks in advance,
db



Bernie Deitrick

programatically merge cells?
 
db,

Sub TryNow()
Dim i As Integer
For i = 0 To 84
Cells(10, i * 3 + 1).Resize(1, 3).Merge
Next i
End Sub

The last cell on row 10 won't be merged....

HTH,
Bernie
MS Excel MVP

"David Bateman" wrote in message
...
I am using Microsoft Excel 2000. How can I write a macro which will
automatically merge every three cells in Row 10. That is merge column a,

b,
c, then d, e, f etc.


Thanks in advance,
db





JE McGimpsey

programatically merge cells?
 
one way:

Public Sub Merge3In10()
Dim i As Long
For i = 1 To Columns.Count - 3 - (Columns.Count Mod 3) Step 3
Cells(10, i).Resize(1, 3).Merge
Next i
End Sub




In article ,
"David Bateman" wrote:

I am using Microsoft Excel 2000. How can I write a macro which will
automatically merge every three cells in Row 10. That is merge column a, b,
c, then d, e, f etc.



All times are GMT +1. The time now is 11:22 AM.

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