Merge and center across from VBA


Posted by Paul on October 10, 2001 7:24 AM

I need to merge a variabel number of cells at the top of my spreadsheet, and place a centered "Title" in them. I am currently doing:

xlSheet.Cells(1, 1).Value = myTitle
xlSheet.Range("a1:a" + Trim(CStr(UBound(myHeadings)))).Merge (True)

The merge doesn't appear to happen, and I haven't yet discovered how to align center this.

Any help would be most appreciated. Thank you.



Posted by cpod on October 10, 2001 12:43 PM

Try this:


Dim intRow As Integer
intRow = UBound(myHeadings)
With xlSheet
.Range("a1", .Cells(1, intRow)).Merge
.Range("a1", .Cells(1, intRow)).HorizontalAlignment = xlCenter
End With