Center Align

  • Thread starter Thread starter John 3:16
  • Start date Start date
J

John 3:16

Hello,

I know that using
xlBook.Worksheets(5).Range("C25..B27").Font.Bold = True
will set the cell attribute for the given range to Bold.

How do I set the alignment to "Center, left or right"

thanks in advance,
bob mcclellan
 
Exampe:

cells(1,1) .HorizontalAlignment = xlRight
cells(1,1).VerticalAlignment = xlRight

Can use xlTop, xlBottom, xlRight, xlLeft
 
Thanks for the reply Bill.
I tried this:
xlBook.Worksheets(5).Range("b25..b27").cells.HorizontalAlignment = xlCenter
This, and other variations I've tried... does not work.
what should the correct syntax be?

thanks in advance,
bob.
 
give this a try

With Worksheets(5).Range("b25..b27")
..HorizontalAlignment = xlCenter
End With
 
Thanks for the reply Gary.

This did not work either.
The error message I receive from the DTS Package is:

Error Source: Microsoft Data Transformation Services(DTS) Package
Error Description: Error Code: 0
Error Source: Microsoft Excel
Error Description: Unable to set the HorizontalAlignment property of the
Range Class
Error on line 53

Not sure why this will not take this syntax.
I used it exactly as per your advice.

thanks in advance,
bob.
 
If anyone is interested...
this was the solution...

..HorizontalAlignment = -4108 ' Center
bob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top