Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy paste non merged to merged cells [email protected] Excel Worksheet Functions 1 February 5th 09 05:25 PM
How can I sort an Excel Doc containing merged & non-merged cells? KellyH Excel Discussion (Misc queries) 11 June 10th 08 04:12 AM
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
how do i link merged cells to a merged cell in another worksheet. ibbm Excel Worksheet Functions 3 April 27th 06 11:40 PM
Sorting merged cellsHow do I sort merged cells not identically siz Laval Excel Worksheet Functions 1 November 3rd 04 09:40 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"