LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 152
Default Centreing Text In Excel Cells

I am send data to an Excel Spreadsheet, which includes some numeric data and
some text data.

I want to have the text in all columns in the centre of the cell. I have
tried lots of different code:-

xlSheet.Range("A:L").HorizontalAlignment = HorizontalAlignment.Center
xlSheet.Cells.HorizontalAlignment = HorizontalAlignment.Center
xlSheet.Columns.HorizontalAlignment = HorizontalAlignment.Center
xlSheet.Cells(10, 1).HorizontalAlignment = HorizontalAlignment.Left
xlSheet.Columns("C").HorizontalAlignment = HorizontalAlignment.Center
xlSheet.Range("A6:L15").HorizontalAlignment = HorizontalAlignment.Center
xlSheet.Cells.HorizontalAlignment = True
xlSheet.Range("A6:L15").HorizontalAlignment = HorizontalAlignment.Center

but nothing seems to work.

If I use horizontalalignment.left the code will not work and I get error
reports.
If I use horizontalalignment.right all the cells requested are aligned to
the left.
If I use horizontalalignment.center the cells are as you would see in a
spreadsheet,
numeric on the right and text on the left of the cell.

All other forms of formatting, i.e. Font.Size, Font.Bold, BorderAround all
work.
The data is being sent to Excel 2000, may seem a bit archaic but it is only
being used to give a direct printout of the data, easier than formatting it
into a document.
--
Alan M
 
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
Need to add text to all cells in excel or merge the text in two ce Juan Maldonado Excel Discussion (Misc queries) 1 September 8th 09 03:11 AM
Excel Changes Text Cells to Number Cells When Importing XML Villerat Excel Discussion (Misc queries) 0 July 24th 08 01:59 AM
3D Text in Excel cells BillM Excel Discussion (Misc queries) 4 February 1st 07 02:18 PM
In Excel, option to enter text in cells the same as text boxes RobGMU Excel Worksheet Functions 0 October 26th 05 04:20 PM
Text cells in excel Julie KD Excel Discussion (Misc queries) 1 May 19th 05 11:52 PM


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

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

About Us

"It's about Microsoft Excel"