PC Review


Reply
Thread Tools Rate Thread

Center the Column Headers

 
 
=?Utf-8?B?QWNjZXNzSGVscA==?=
Guest
Posts: n/a
 
      15th Oct 2007
I have values in Cells A1, B1 and C1 in a new sheet. How can I align them to
center? I have tried the following:

NewSheet.Rows(1).align msoAlignCenter, true

Thanks.
 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      15th Oct 2007
Fo just A1:C1
Range("A1:C1").HorizontalAlignment = xlCenter

For the whole first row
Rows(1).HorizontalAlignment = xlCenter

AccessHelp wrote:
> I have values in Cells A1, B1 and C1 in a new sheet. How can I align them to
> center? I have tried the following:
>
> NewSheet.Rows(1).align msoAlignCenter, true
>
> Thanks.


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      15th Oct 2007
Did you try recording a macro while doing it manually

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"AccessHelp" <(E-Mail Removed)> wrote in message
news:BA6CC3AA-2C12-40D8-A725-(E-Mail Removed)...
>I have values in Cells A1, B1 and C1 in a new sheet. How can I align them
>to
> center? I have tried the following:
>
> NewSheet.Rows(1).align msoAlignCenter, true
>
> Thanks.


 
Reply With Quote
 
ryan.fitzpatrick3@safeway.com
Guest
Posts: n/a
 
      15th Oct 2007
On Oct 15, 9:33 am, JW <JWRIGH...@triad.rr.com> wrote:
> Fo just A1:C1
> Range("A1:C1").HorizontalAlignment = xlCenter
>
> For the whole first row
> Rows(1).HorizontalAlignment = xlCenter
>
> AccessHelp wrote:
> > I have values in Cells A1, B1 and C1 in a new sheet. How can I align them to
> > center? I have tried the following:

>
> > NewSheet.Rows(1).align msoAlignCenter, true

>
> > Thanks.


Record a macro, then highlight the columns you want to center than use
the center align button then stop macro. It's good to use the record
macro for simple tasks such as this; this way you can get a basic
understanding about vba.

ryan

 
Reply With Quote
 
=?Utf-8?B?QWNjZXNzSGVscA==?=
Guest
Posts: n/a
 
      15th Oct 2007
JW,

Thanks for your help. The code works perfectly.

"JW" wrote:

> Fo just A1:C1
> Range("A1:C1").HorizontalAlignment = xlCenter
>
> For the whole first row
> Rows(1).HorizontalAlignment = xlCenter
>
> AccessHelp wrote:
> > I have values in Cells A1, B1 and C1 in a new sheet. How can I align them to
> > center? I have tried the following:
> >
> > NewSheet.Rows(1).align msoAlignCenter, true
> >
> > Thanks.

>
>

 
Reply With Quote
 
=?Utf-8?B?QWNjZXNzSGVscA==?=
Guest
Posts: n/a
 
      16th Oct 2007
Thanks for your response. No, I didn't record the macro. I wrote the code
from scratch, and this line item is just a portion of my entire code. One of
the challenges that I have is I am still new to Excel syntax.

Thanks.

"Don Guillett" wrote:

> Did you try recording a macro while doing it manually
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "AccessHelp" <(E-Mail Removed)> wrote in message
> news:BA6CC3AA-2C12-40D8-A725-(E-Mail Removed)...
> >I have values in Cells A1, B1 and C1 in a new sheet. How can I align them
> >to
> > center? I have tried the following:
> >
> > NewSheet.Rows(1).align msoAlignCenter, true
> >
> > Thanks.

>
>

 
Reply With Quote
 
=?Utf-8?B?QWNjZXNzSGVscA==?=
Guest
Posts: n/a
 
      16th Oct 2007
Hi Ryan,

Thanks for your response. As I mentioned to Don below, this line item is
just a portion of my entire code. Plus, I am still new to Excel syntax.

Thanks.

"(E-Mail Removed)" wrote:

> On Oct 15, 9:33 am, JW <JWRIGH...@triad.rr.com> wrote:
> > Fo just A1:C1
> > Range("A1:C1").HorizontalAlignment = xlCenter
> >
> > For the whole first row
> > Rows(1).HorizontalAlignment = xlCenter
> >
> > AccessHelp wrote:
> > > I have values in Cells A1, B1 and C1 in a new sheet. How can I align them to
> > > center? I have tried the following:

> >
> > > NewSheet.Rows(1).align msoAlignCenter, true

> >
> > > Thanks.

>
> Record a macro, then highlight the columns you want to center than use
> the center align button then stop macro. It's good to use the record
> macro for simple tasks such as this; this way you can get a basic
> understanding about vba.
>
> ryan
>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      16th Oct 2007
Had you "tried" to record a macro, this is what you would have gotten. Then,
just clean it up as shown below it.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 10/16/2007 by Donald B. Guillett
'

'
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub

sub centerrowtext()'cleaned up
Rows("1:1").HorizontalAlignment = xlCenter
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"AccessHelp" <(E-Mail Removed)> wrote in message
news:883A9928-984D-4D5C-8E2C-(E-Mail Removed)...
> Thanks for your response. No, I didn't record the macro. I wrote the
> code
> from scratch, and this line item is just a portion of my entire code. One
> of
> the challenges that I have is I am still new to Excel syntax.
>
> Thanks.
>
> "Don Guillett" wrote:
>
>> Did you try recording a macro while doing it manually
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "AccessHelp" <(E-Mail Removed)> wrote in message
>> news:BA6CC3AA-2C12-40D8-A725-(E-Mail Removed)...
>> >I have values in Cells A1, B1 and C1 in a new sheet. How can I align
>> >them
>> >to
>> > center? I have tried the following:
>> >
>> > NewSheet.Rows(1).align msoAlignCenter, true
>> >
>> > Thanks.

>>
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
lookup using column headers and row headers Memphus01 Microsoft Excel Misc 1 13th Apr 2009 04:57 PM
Hide Column Headers but not row (Headers) Kevan Gradwell Microsoft Excel Programming 1 16th Mar 2007 05:59 PM
Column Headers are numeric as the Row Headers =?Utf-8?B?TWFyayBCdXJzaWFu?= Microsoft Excel Crashes 3 21st Feb 2007 04:56 PM
How to set Column headers as row headers in Data grid control =?Utf-8?B?VlIgUmF2aW51dGhhbGE=?= Microsoft Dot NET Framework Forms 1 3rd May 2005 12:25 AM
How to center column headers in listview without centering column data? Rubbrecht Philippe Microsoft Dot NET Framework Forms 0 5th Aug 2003 12:35 PM


Features
 

Advertising
 

Newsgroups
 


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