Microsoft Office Tutorials and References
In Depth Information
19.3.6 AutoFit Method
The code:
Range("A1:B5").AutoFilter 2, "1997", xlOr, "1998"
will filter the range A1:B5 to show only those rows in the range for either the year 1997 or 1998.
Note that it has no effect on the remaining rows of the worksheet. Hence, the result will be the
worksheet in Figure 19-5 w ith rows 3 and 4 missing.
Recall that the AutoFilterMode property of the Worksheet object is True if the AutoFilter
dropdown arrows are currently displayed on the worksheet. Note that we can set this property to
False to remove the arrows, but we cannot set it to True . (To display the AutoFilter arrows, use
the AutoFilter method.)
Recall also that the FilterMode property is True if the worksheet is in filter mode. Thus, for
instance, if the AutoFilter arrows are displayed but no filtering has taken place, then
AutoFilterMode is True , whereas FilterMode is False . Once filtering is actually performed, then
FilterMode is True .
19.3.6 AutoFit Method
This method changes the width of the columns or the height of the rows (depending upon the type
of range) to obtain the best fit for the range's contents. The syntax is:
RangeObject .AutoFit
where RangeObject refers to a Range object that consists of either one or more rows or one or
more columns (but not both). Otherwise, the method generates an error. If the range consists of
columns, then the column width is adjusted. If the range consists of rows, then the row height is
adjusted.
19.3.7 AutoFormat Method
This method automatically formats a range using a predefined format. The syntax is:
RangeObject .AutoFormat( Format , Number , Font , _
Alignment , Border , Pattern , Width )
All parameters of this method are optional. The Format parameter can be one of the following
XlRangeAutoFormat constants:
Search JabSto ::




Custom Search