Formating a column in Excel programmatically
-
I want to format a column so that all the cells in that column are percentage. Instead of doing this manually (highlight a column, right=click and select Format Cells..., and then change the Category to Percentage) I want to do it programmatically. Here is an example of how I did some formatting” 'WORD WRAP oWorkSheet.Cells.WrapText = True 'BOLD COLUMN HEADERS oWorkSheet.Range("A1", "CC1").Font.Bold() = True 'COLUMN WIDTH oWorkSheet.Columns(1).columnWidth() = 16.5 Thanks
-
I want to format a column so that all the cells in that column are percentage. Instead of doing this manually (highlight a column, right=click and select Format Cells..., and then change the Category to Percentage) I want to do it programmatically. Here is an example of how I did some formatting” 'WORD WRAP oWorkSheet.Cells.WrapText = True 'BOLD COLUMN HEADERS oWorkSheet.Range("A1", "CC1").Font.Bold() = True 'COLUMN WIDTH oWorkSheet.Columns(1).columnWidth() = 16.5 Thanks
How does this work for you?
Columns("A").NumberFormat = "0.00%"
I've always found that if I have to do some VBA, then I create and record a new macro, do what I want, then edit the macro to find out how Excel creates the code. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty