ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help (https://www.excelbanter.com/excel-programming/390219-help.html)

Donna

help
 
can anybody explain offset propety to me please?

Many thanks

Bob Phillips

help
 
Offset property as it applies to the Range object.
Returns a Range object that represents a range that's offset (by the
specified number of rows and/or columns) from the specified range.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"donna" wrote in message
...
can anybody explain offset propety to me please?

Many thanks




joel

help
 
Offset is the number of rows and columns from a given cell. The general form
is

Cells(5,"D").offset(rowoffset:=5,columnoffset:=3). value (cell G10)

It can be abbriaviated as

Cells(5,"D").offset(5,3).value

It doesn't have to be agains a cells. It could be

activecell.offset(5,3).value


Note: Row and Column offset can be negative, but cannot go off the
worksheet. It is not valid if you are om Row 1 to go negative offset, or at
Column A have a negaive offset.

"donna" wrote:

can anybody explain offset propety to me please?

Many thanks


Don Guillett

help
 
from help index for
OFFSET

See Also

Returns a reference to a range that is a specified number of rows and
columns from a cell or range of cells. The reference that is returned can be
a single cell or a range of cells. You can specify the number of rows and
the number of columns to be returned.

Syntax

OFFSET(reference,rows,cols,height,width)

Reference is the reference from which you want to base the offset.
Reference must refer to a cell or range of adjacent cells; otherwise, OFFSET
returns the #VALUE! error value.

Rows is the number of rows, up or down, that you want the upper-left cell
to refer to. Using 5 as the rows argument specifies that the upper-left cell
in the reference is five rows below reference. Rows can be positive (which
means below the starting reference) or negative (which means above the
starting reference).

Cols is the number of columns, to the left or right, that you want the
upper-left cell of the result to refer to. Using 5 as the cols argument
specifies that the upper-left cell in the reference is five columns to the
right of reference. Cols can be positive (which means to the right of the
starting reference) or negative (which means to the left of the starting
reference).

Height is the height, in number of rows, that you want the returned
reference to be. Height must be a positive number.

Width is the width, in number of columns, that you want the returned
reference to be. Width must be a positive number.

Remarks

a.. If rows and cols offset reference over the edge of the worksheet,
OFFSET returns the #REF! error value.

b.. If height or width is omitted, it is assumed to be the same height or
width as reference.

c.. OFFSET doesn't actually move any cells or change the selection; it
just returns a reference. OFFSET can be used with any function expecting a
reference argument. For example, the formula SUM(OFFSET(C2,1,2,3,1))
calculates the total value of a 3-row by 1-column range that is 1 row below
and 2 columns to the right of cell C2.

Example

The example may be easier to understand if you copy it to a blank worksheet.

How?

1.. Create a blank workbook or worksheet.
2.. Select the example in the Help topic. Do not select the row or column
headers.


Selecting an example from Help

3.. Press CTRL+C.
4.. In the worksheet, select cell A1, and press CTRL+V.
5.. To switch between viewing the results and viewing the formulas that
return the results, press CTRL+` (grave accent), or on the Tools menu, point
to Formula Auditing, and then click Formula Auditing Mode.

1
2
3
4
A B
Formula Description (Result)
=OFFSET(C3,2,3,1,1) Displays the value in cell F5 (0)
=SUM(OFFSET(C3:E5,-1,0,3,3)) Sums the range C2:E4 (0)
=OFFSET(C3:E5,0,-3,3,3) Returns an error, because the reference
is not on the worksheet (#REF!)



--
Don Guillett
SalesAid Software

"donna" wrote in message
...
can anybody explain offset propety to me please?

Many thanks



Dave Peterson

help
 
After all the explanations you have, maybe it's time to experiment.

Create a new worksheet (and make sure it's active).

Then run this macro:

Option Explicit
Sub testme()
Dim myRng As Range
With ActiveSheet
.Cells.Interior.ColorIndex = xlNone
Set myRng = .Range("a1:c1,f9,h12")
myRng.Interior.ColorIndex = 5
myRng.Offset(1, 3).Interior.ColorIndex = 3
End With
End Sub

Change myRng to any range you want, then look at the colors on that sheet.

Then experiment with the .offset() numbers.

And when you're done, take a look at the .resize() property, too!

donna wrote:

can anybody explain offset propety to me please?

Many thanks


--

Dave Peterson


All times are GMT +1. The time now is 01:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com