Excel Range: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
mNo edit summary
Line 3: Line 3:
[[File:Range.jpg]]<br />
[[File:Range.jpg]]<br />
All examples show cells of the selected range in yellow.
All examples show cells of the selected range in yellow.
== Used Range ==
<syntaxhighlight lang="autoit">$oRange = $oWorkBook.Activesheet.UsedRange</syntaxhighlight>
Selects all cells which have a value now or had a value before (means: all cells which had been touched by the user or a script).<br />
Note that the range does not contain row 1 and column 1!<br />
[[File:Range_UsedRange.jpg]]<br />
== Entire Row / Entire Column ==
<syntaxhighlight lang="autoit">$oRange = $oWorkBook.Activesheet.Range("B2").EntireRow</syntaxhighlight>
Selects the entire row(s) of the specified range.<br />
[[File:Range_EntireRow.jpg]]<br />
Use method "EntireColumn" to select the columns for the specified range.


== Current Region ==
== Current Region ==
Line 19: Line 9:
[[File:Range_CurrentRegion.jpg]]<br />
[[File:Range_CurrentRegion.jpg]]<br />
Note that cell B6 is not part of the region. The cell has been touched before but now is blank and hence bounds the region.
Note that cell B6 is not part of the region. The cell has been touched before but now is blank and hence bounds the region.
== Empty Cells ==
== Empty Cells ==
<syntaxhighlight lang="autoit">$oRange = $oWorkbook.ActiveSheet.UsedRange.SpecialCells($xlCellTypeBlanks)</syntaxhighlight>
<syntaxhighlight lang="autoit">$oRange = $oWorkbook.ActiveSheet.UsedRange.SpecialCells($xlCellTypeBlanks)</syntaxhighlight>
Marks all empty cells in the specified range.<br />
Marks all empty cells in the specified range.<br />
[[File:Range_EmptyCells.jpg]]<br />
[[File:Range_EmptyCells.jpg]]<br />
== Entire Row / Entire Column ==
<syntaxhighlight lang="autoit">$oRange = $oWorkBook.Activesheet.Range("B2").EntireRow</syntaxhighlight>
Selects the entire row(s) of the specified range.<br />
[[File:Range_EntireRow.jpg]]<br />
Use method "EntireColumn" to select the columns for the specified range.
== Used Range ==
<syntaxhighlight lang="autoit">$oRange = $oWorkBook.Activesheet.UsedRange</syntaxhighlight>
Selects all cells which have a value now or had a value before (means: all cells which had been touched by the user or a script).<br />
Note that the range does not contain row 1 and column 1!<br />
[[File:Range_UsedRange.jpg]]<br />

Revision as of 15:59, 31 October 2014

On this page you will find some special ranges and how to define them in AutoIt.
As input file I will use the following Excel workbook. All cells which have a value now or had a value before (means: all cells which had been touched by the user or a script) are displayed in grey.

All examples show cells of the selected range in yellow.

Current Region

$oRange = $oWorkBook.Activesheet.Range("B4").CurrentRegion

The current region is a range bounded by any combination of blank rows and blank columns.

Note that cell B6 is not part of the region. The cell has been touched before but now is blank and hence bounds the region.

Empty Cells

$oRange = $oWorkbook.ActiveSheet.UsedRange.SpecialCells($xlCellTypeBlanks)

Marks all empty cells in the specified range.

Entire Row / Entire Column

$oRange = $oWorkBook.Activesheet.Range("B2").EntireRow

Selects the entire row(s) of the specified range.

Use method "EntireColumn" to select the columns for the specified range.

Used Range

$oRange = $oWorkBook.Activesheet.UsedRange

Selects all cells which have a value now or had a value before (means: all cells which had been touched by the user or a script).
Note that the range does not contain row 1 and column 1!