距离偏移量 [英] Range.offset propety

查看:112
本文介绍了距离偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图理解VBA上的代码,以调试某人的VBA程序.所以我想知道那是Range(Value).offset(x; y)的属性和含义.这是我的代码:

I'm trying to understand a code on VBA, to debug the VBA program of someone. So I want to know that is the property and the meaning of Range (Value).offset(x;y). Here is my code:

`Sub initialise()
Dim i As Double, j As Double
For i = 0 To maxnodes - 1
For j = 0 To 1
    **If Range(initial_range).Offset(i, j) <> 0 Then**
       Range(Startrange).Offset(i, j) = Range(initial_range).Offset(i, j)
    Else
       Range(Startrange).Offset(i, j) = Empty
    End If
Next j
Next i

End Sub`

能帮我吗?如果您需要更多详细信息,则不存在

Can you help me please? If you need more details, don't exist

推荐答案

.Offset 属性用于从指定位置移动特定位置.

The .Offset property is used to move a certain position from a specified location.

它的用法类似于:

ActiveSheet.Cells(1, 1).Offset(Row, Column)

当正值将行值的位置向下(按规定量)移动时,将列值的位置向右(按规定量)移动时.负值的移动方向相反.

Where positive values move the position down (by the stated amount) for the Row value, and to the right (by the stated amount) for the column value. Negative values move in the opposite way.

因此,类似于 ActiveSheet.Cells(1,1).Offset(2,0)的东西(其中 ActiveSheet.Cells(1,1)表示单元格 A1 )实际上是指 cells(3,1) A3 .

Therefore, something like ActiveSheet.Cells(1,1).Offset(2, 0) (Where ActiveSheet.Cells(1,1) represents cell A1) Would actually be referring to cells(3, 1) or A3.

因此,在您的代码中使用for循环和offset属性;代码使用所有不等于0的值创建一个新矩阵.(同样,您需要删除 ** 使其运行)

Therefore, in your code using the for loop and the offset property; the code is creating a new matrix using all the values that aren't equal to 0. (also you will need to remove the ** to get it to run)

这篇关于距离偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆