Defining Ranges

You can use the Height property to determine the total height of a specific range. Excel returns the height of the range as a point value. The Height property is read-only and you cannot modify it. You can return the height by assigning the value to a variable, as shown in this code:

TYPE THIS:

RESULT:

The code assigns the total height of the rows specified by the NewRange object to the HeightofRange variable. As in the steps, you can take the value returned to the HeightofRange variable and divide it by the number of rows in the range to create an average height for each row.

The Range object provides two properties that you can use to determine the distance of a range from the top corner of a worksheet, cell A1. Each property returns a point measurement indicating the corresponding distance. The Left property measures the distance from the left edge of column A to the left edge of the specified range. The Top property measures the distance from the top edge of row 1 to the top edge of the specified range.

I Type NewRange.Rows(N) .RowHeight = AverageHeight.

— Switch to Excel and run the macro.

■ Excel resizes the rows in the specified range to be the same height.

Note: See Chapter 6 for more information on using the For Next looping statement.

I Type NewRange.Rows(N) .RowHeight = AverageHeight.

Type Next.

— Switch to Excel and run the macro.

■ Excel resizes the rows in the specified range to be the same height.

0 0

Post a comment