What is a Range object?The Range object represents a range of cells within a worksheet. A Range object may include non-adjacent areas (with ExcelWriter 3 or higher). To create a Range object, use, Cells.Range, Cells.Rows, or Cells.Columns. The property set Rng = Cells.Range(3,10,2,5)
Range properties and methods
Example 1: OutlinesRange2.asp uses GroupColumns* and GroupRows* to create outlines within a range. The first row or column in an outline is the summary row or column, and is always
visible. The rows or columns following
the summary are the outline detail rows or columns, and will be visible or hidden,
depending on the value of the
*This feature is not available in ExcelWriterSE, ExcelWriterLE, or ExcelWriter Free. Example 2: Union, Intersection, Names, and OutlinesThe following example imports data from the Northwind database to an Excel spreadsheet. The script sets five ranges, and names each using the Name* property. The range names will be listed in Excel's drop-down name box above the top left corner of the spreadsheet. Select a range name from the list to highlight a range. Range1 is defined as the set of cells beginning at row 4, column 2, and spanning 4 rows and 5 columns: Set Range1 = ws1.cells.range(4,2,4,5) Later Range1 is redefined using the Union* method, which creates a union of the two ranges Range1 and Range2: Range1.union(Range2) Range2 - originally the set of cells from cell (6,3) to cell (12,11) - is redefined by the Intersect* method as the intersection of Range2 and Range3: Range2.intersect(Range3) GroupColumns*
and GroupRows*
are used to create outlines within Range4 and Range5. The first row or column in an
outline is the summary row or column, and is always visible. The rows or columns following
the summary are the outline detail rows or columns, and will be visible or hidden,
depending on the value of the Range4.GroupColumns 13,7,True *This feature is not available in ExcelWriterSE, ExcelWriterLE, or ExcelWriter Free. Example 3: Use Range to Set PrintArea*Range can be used to assign a certain group of cells to ExcelWriter's PrintArea* property. PrintArea* is simply a Range that is read by the PageSetup* object when determining the portion of the page that should be printed. A Range can be directly assigned to a PrintArea*: Ws.PageSetup.PrintArea = Ws.Cells.Range(1, 1, 20, 10) Or it can be assigned to a variable which can be used to set the PrintArea*: Set pa = Ws.Cells.Range(1, 1, 20, 10) Ws.PageSetup.PrintArea = pa *This feature is not available in ExcelWriterSE, ExcelWriterLE, or ExcelWriter Free. Example 4: Using Range to Display TextThe following sample uses MergeCells* to display a large block of text within a range of cells. *This feature is not available in ExcelWriterSE, ExcelWriterLE, and ExcelWriterFree. Example 5: Applying a Border to a Range of CellsBorderAround.asp creates a function called Example 6: Assigning Values from an Array with Range.Value*RangeValue1.asp assigns values to a block of cells from a 2-dimentional array using the
*This feature is not available in ExcelWriterSE, ExcelWriterLE, and ExcelWriterFree. Example 7: Getting Values from a Worksheet with Range.Value*RangeValue2.asp gets values from a worksheet and populates a 2D array using
the *This feature is not available in ExcelWriterSE, ExcelWriterLE, and ExcelWriterFree. Example 8: Applying a Style to a Range of CellsThis samples demonstrates how to use Range.Style* to apply a style to a range of cells, and then use Cell.Format refine the style of specific cells. *This feature is not available in ExcelWriterSE, ExcelWriterLE, and ExcelWriterFree.
Copyright © 2003, SoftArtisans, Inc. |
|||||||||||||||||||||||||||||||||||||||||||