Excel Offset property - VBA
Offset property
--------------------
offset property allows 2 arguments that correspond to the position on the cell. Example
--------
Object.offset (RowOffset, ColumnOffset)
ActiveCell.Offset (0, 0). Select 'as we put 0 for the arguments row and column selection
remains our initial active cell.
Activecell.0ffset (1.0). Select 'now the active cell is a line below
' if our initial active cell hubise now been active cell A1 A2 would
Activecell.0ffset Msgbox (1 , 0).
address
is also important to note that you get an error if you assign or tratamoos we move to a range of non-existent.
eg ActiveCell.Offset (-5, 0). Select 'we throw an error because there is no range is selected it would be 5 rows up from A2.
Similarly we can move between varying the value colmnas ColumnOffset
ActiveCell.Offset (0, 1). Select 'Move one column to the right
We may also use these arguments (RowOffset, ColumnOffset) to indicate where to move or assign a value to a particular cell. Sub
sample_vba_offset ()
As Range Dim RANGE RANGE
September
= Range ("B1")
RANGO.Offset (2, 4). Value = "27 May Champions Grand Final League - 2009 "
'we move below 2 rows and 4 columns to the right
End Sub' eye ... the same way you get an error if we try to move or assign a value to a range not existing.
ActiveCell.Offset (0, -3). Select 'move 3 columns to the left
0 comments:
Post a Comment