Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to justify in merged cells
I have merged 5 cells horizontally with:
objSht.Range("A1:E1").Merge objSht.Cells(1, 1) = "My Report Title" How can I center the report title in the merged cells? Bill |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to justify in merged cells
I detest merging, since it screws up selections, formatting, sorting,
etc. I'd suggest instead that you center across A1:E1. Something like this: Dim rOldSelection As Range Application.ScreenUpdating = False Set rOldSelection = Selection Application.Goto objSheet.Range("A1:E1") With Selection .Item(1).Value = "My Title" .HorizontalAlignment = xlCenterAcrossSelection End With Application.Goto rOldSelection Application.ScreenUpdating = True It's one of the few times I recommend using Select. In article , "Bill Murphy" wrote: I have merged 5 cells horizontally with: objSht.Range("A1:E1").Merge objSht.Cells(1, 1) = "My Report Title" How can I center the report title in the merged cells? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to justify in merged cells
Try:
With objSht.Range("A1:E1") .MergeCells = True .Value = "My Report Title" .HorizontalAlignment = xlHAlignCenter End With Regards, Greg -----Original Message----- I have merged 5 cells horizontally with: objSht.Range("A1:E1").Merge objSht.Cells(1, 1) = "My Report Title" How can I center the report title in the merged cells? Bill . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to justify in merged cells
It's one of the few times I recommend using Select.
Is it necessary to Select? This worked for me: Sub test() Dim objSheet As Worksheet Set objSheet = Worksheets("Sheet3") With objSheet.Range("A1:E1") ..Clear ..HorizontalAlignment = xlCenterAcrossSelection ..VerticalAlignment = xlVAlignCenter '.BorderAround 1 ' and whatever ..Cells(1).Value = "My Report Title" End With End Sub Regards, Peter -----Original Message----- I detest merging, since it screws up selections, formatting, sorting, etc. I'd suggest instead that you center across A1:E1. Something like this: Dim rOldSelection As Range Application.ScreenUpdating = False Set rOldSelection = Selection Application.Goto objSheet.Range("A1:E1") With Selection .Item(1).Value = "My Title" .HorizontalAlignment = xlCenterAcrossSelection End With Application.Goto rOldSelection Application.ScreenUpdating = True It's one of the few times I recommend using Select. In article , "Bill Murphy" wrote: I have merged 5 cells horizontally with: objSht.Range("A1:E1").Merge objSht.Cells(1, 1) = "My Report Title" How can I center the report title in the merged cells? . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to justify in merged cells
No, it's not.
For me it's a totemic holdover - I had problems with it years ago in a previous version of XL (I don't recall why, but I recall it as a project from hell), so ever since I've used a custom function that actually does the selection. Time for me to lose that superstition. In article , "Peter T" wrote: It's one of the few times I recommend using Select. Is it necessary to Select? This worked for me: |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to justify in merged cells
For me it's a totemic holdover I have quite a few of those, never found quite the right expression to capture so succinctly. I'll use it at the earliest opportunity :) Peter |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to justify in merged cells
Thanks to all of you for your solutions, all of which work!
Bill "Bill Murphy" wrote in message ... I have merged 5 cells horizontally with: objSht.Range("A1:E1").Merge objSht.Cells(1, 1) = "My Report Title" How can I center the report title in the merged cells? Bill |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy paste non merged to merged cells | Excel Worksheet Functions | |||
How can I sort an Excel Doc containing merged & non-merged cells? | Excel Discussion (Misc queries) | |||
Autofit Merged cell Code is changing the format of my merged cells | Excel Discussion (Misc queries) | |||
how do i link merged cells to a merged cell in another worksheet. | Excel Worksheet Functions | |||
Sorting merged cellsHow do I sort merged cells not identically siz | Excel Worksheet Functions |