![]() |
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 |
Centreing Text In Excel Cells
Alan -
Maybe xlSheet.Range("A:L").HorizontalAlignment = xlCenter "Alan" wrote: 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 |
All times are GMT +1. The time now is 10:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com