Loading

Sunday, March 1, 2009

Changing Row and Column Size

Sometimes, in Microsoft Excel we need to change width of columns or height of rows in a worksheet to accomodate data they contain. In Excel Visual Basic for Application (VBA macro), to change columns width we can use ColumnWidth property. Following excel macro code sets width of column C in "Sheet1" worksheet to 24:

Sheets("Sheet1").Columns("C").ColumnWidth = 24

To change columns width to fit data in columns, we can use AutoFit method. The following example uses AutoFit method to change the size of C:F in the "Sheet1" worksheet:

Sheets("Sheet1").Columns("C:F").AutoFit

RowHeight property is used to change rows height of a range. For example:

Sheets("Sheet1").Rows(2).RowHeight = 56

SHARE TWEET

Thank you for reading this article Changing Row and Column Size With URL https://x-tutorials.blogspot.com/2009/03/changing-row-and-column-size.html. Also a time to read the other articles.

0 comments:

Write your comment for this article Changing Row and Column Size above!