您好,欢迎来到中国最大的生活服务网站![登录][注册]
版主:Mniwtian   副版主:
点击查看所有副版主

topics in the next chapter.

The Offset property

The Offset property, like the Range and Cells properties, also returns a Range object. But unlike the other two methods that I discussed, the Offset property applies only to a Range object and no other class. Its syntax is as follows:

 

object.Offset(rowOffset, columnOffset)

 

The Offset property takes two arguments that correspond to the relative position from the upper-left cell of the specified Range object. The arguments can be positive (down or to the right), negative (up or to the left), or zero. The example that follows enters a value of 12 into the cell directly below the active cell:

 

ActiveCell.Offset(1,0).Value = 12

 

The next example enters a value of 15 into the cell directly above the active cell:

 

ActiveCell.Offset(-1,0).Value = 15

 

If the active cell is in row 1, the Offset property in the preceding example generates an error because it cannot return a Range object that doesn''t exist.

 

The Offset property is quite useful, especially when you use variables within looping procedures. I discuss these

 

When you record a macro using the relative reference mode, Excel uses the Offset property to reference cells relative to the starting position (that is, the active cell when macro recording begins). For example, I used the macro recorder to generate the following code. I started with the cell pointer in cell B1, entered values into B1:B3, and then returned to B1.

用户名: 请您登录后再发帖 
标 题: 标题请勿超过30个字
内 容:
 
  请阅读我们的[服务条款]
Copyright © 2009 Yahoo.com.cn 版权所有 不得转载 | 使用须知 | 著作权声明 | 京ICP证000022号 | 国家药监局(京)-经营性-2004-0039
全球阿里巴巴 - 阿里巴巴网络:中国站 国际站 日文站 | 淘宝站 | 支付宝 | 中国雅虎 | 口碑网 | 阿里软件 | 阿里妈妈