Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Center the Column Headers

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Center the Column Headers

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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Center the Column Headers

Did you try recording a macro while doing it manually

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"AccessHelp" wrote in message
...
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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Center the Column Headers

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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Center the Column Headers

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

"AccessHelp" wrote in message
...
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.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Center the Column Headers

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.

" wrote:

On Oct 15, 9:33 am, 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.


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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Center the Column Headers

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

"AccessHelp" wrote in message
...
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

"AccessHelp" wrote in message
...
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
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
lookup using column headers and row headers Memphus01 Excel Discussion (Misc queries) 1 April 13th 09 04:57 PM
Merge and Center and Center Accross Selection Bojingles03 New Users to Excel 3 March 17th 09 07:05 PM
Macro code to center pasted data in a column Rich K. Excel Discussion (Misc queries) 2 July 9th 07 04:50 PM
Hide Column Headers but not row (Headers) Kevan Gradwell Excel Programming 1 March 16th 07 05:59 PM
Loop through column headers to search from column name and get cell range Pie Excel Programming 9 December 29th 05 12:17 AM


All times are GMT +1. The time now is 08:59 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"