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.

 

Following table provides the  properties of  the WksRange object:

 

Property

Description

Application

Returns the application object. It is a read-only property.

Column

Returns the first column in the Range.  It is a read-only property.

ColumnCount

Returns the number of columns in the Range.  It is a read-only property.

ColumnWidth

Returns/sets the column width of all the columns in the Range.  Returns null if not all the column widths are the same.

Count

Returns the number of cells in the Range.  It is a read-only property.

EntireColumn

Returns a new Range containing every cell in each column of the current Range.  It is a read-only property.

EntireRow

Returns a new Range containing every cell in each row of the current Range.  It is a read-only property.

Format

Returns the CellFormat object used by the cells in the Range.  It is a read-only property.

IsEntireColumn

Returns True if the Range contains entire columns.  It is a read-only property.

IsEntireRow

Returns True if the Range contains whole rows.  It is a read-only property.

LastColumn

Returns the last column in the Range.  It is a read-only property.

LastRow

Returns the last row in the Range.  It is a read-only property.

Name

Returns the text description of the Range.  It is a read-only property.

Parent

Returns the worksheet associated with this Range.   It is a read-only property.

Row

Returns the first row in the Range.  It is a read-only property.

RowCount

Returns the number of rows in the Range. It is a read-only property.

RowHeight

Returns/sets the row height of all the rows in the Range.  Returns null if not all the row heights are the same.

Value

Returns/sets the cell values in the Range.

 

 

Following table provides the methods of the WksRange object:

 

Method

Description

Cells

Returns a new Range.  The specified coordinates are relative to the top-left cell in the current Range.

Clear [WksRange]

Deletes the contents and formatting of all the cells in the Range.

Columns

Returns a Range containing all or some of the columns of the current Range.

Copy

Copies all the cells in the Range into the clipboard.

Cut

Copies all the cells in the Range into the clipboard and clears the contents and formatting of the cells.

Delete

Deletes the cells in the Range and shifts the remaining cells either up or to the left.

Find

Find a target string within range.

Insert

Shifts the current cells down or to the right and inserts blank cells in their place.

NumberToText

Convert numeric cells to text cells.

Paste

Inserts the contents of the clipboard into the Range area.  Will not paste into cells that lie outside the Range.

PasteSpecial

Inserts clipboard contents using the specified format into the Range area.  Will not paste into cells that lie outside the Range.

Replace

Replace a target string with the replacement string within range.

Rows

Returns a Range containing all or some of the rows in the current Range.

Sort

Sorts the cells in the Range from top to bottom.

Statistics

Calculates statistics on all the columns in the Range.

TextToNumber

Convert text cells to numeric cells.

Transpose

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