WksRange Object
The WksRange object represents one or more cells within a worksheet. Methods exist to copy the cells, change cell formatting, sort columns, and calculate column statistics.
The following table provides the properties of the WksRange object:
Property |
Description |
Returns the application object. It is a read-only property. |
|
Returns the first column in the Range. It is a read-only property. |
|
Returns the number of columns in the Range. It is a read-only property. |
|
Returns/sets the column width of all the columns in the Range. Returns null if not all the column widths are the same. |
|
Returns the number of cells in the Range. It is a read-only property. |
|
Returns a new Range containing every cell in each column of the current Range. It is a read-only property. |
|
Returns a new Range containing every cell in each row of the current Range. It is a read-only property. |
|
Returns the CellFormat object used by the cells in the Range. It is a read-only property. |
|
Returns True if the Range contains entire columns. It is a read-only property. |
|
Returns True if the Range contains whole rows. It is a read-only property. |
|
Returns the last column in the Range. It is a read-only property. |
|
Returns the last row in the Range. It is a read-only property. |
|
Returns the text description of the Range. It is a read-only property. |
|
Returns the worksheet associated with this Range. It is a read-only property. |
|
Returns the first row in the Range. It is a read-only property. |
|
Returns the number of rows in the Range. It is a read-only property. |
|
Returns/sets the row height of all the rows in the Range. Returns null if not all the row heights are the same. |
|
Returns/sets the cell values in the Range. |
The following table provides the methods of the WksRange object:
Method |
Description |
Returns a new Range. The specified coordinates are relative to the top-left cell in the current Range. |
|
Deletes the contents and formatting of all the cells in the Range. |
|
Returns a Range containing all or some of the columns of the current Range. |
|
Copies all the cells in the Range into the clipboard. |
|
Copies all the cells in the Range into the clipboard and clears the contents and formatting of the cells. |
|
Deletes the cells in the Range and shifts the remaining cells either up or to the left. |
|
Find a target string within range. |
|
Shifts the current cells down or to the right and inserts blank cells in their place. |
|
Convert numeric cells to text cells. |
|
Inserts the contents of the clipboard into the Range area. Will not paste into cells that lie outside the Range. |
|
Inserts clipboard contents using the specified format into the Range area. Will not paste into cells that lie outside the Range. |
|
Replace a target string with the replacement string within range. |
|
Returns a Range containing all or some of the rows in the current Range. |
|
Sorts the cells in the Range from top to bottom. |
|
Calculates statistics on all the columns in the Range. |
|
Convert text cells to numeric cells. |
|
Transpose row and column data in the Range. |
Example
The following script demonstrates how the WksRange object is used in reference to the Columns property.
Sub Main
'Declares SurferApp as an object
Dim SurferApp As Object
'Creates an instance of the Surfer Application object and assigns
'it to the variable named "SurferApp"
Set SurferApp = CreateObject("Surfer.Application")
'Makes Surfer visible
SurferApp.Visible = True
'Declares Wks as an object
Dim Wks As Object
'Opens a worksheet document in Surfer and assigns it to the
'variable named "Wks"
Set Wks = SurferApp.Documents.Open(FileName:=SurferApp.Path+"\Samples\demogrid.dat")
'Declares WksRange as an object
Dim WksRange As Object
'Assigns Columns A, B, and C to the variable named "WksRange"
Set WksRange = Wks.Columns(Col1:=1, Col2:=3)
End Sub