VBA 438错误 - 对象不支持此属性/方法

时间:2013-07-29 19:02:17

标签: vba excel-vba runtime excel

我根本没有太多的VBA经验,但这就是我想要做的事情(代码如下):

我有两张纸 - 一张是模具,另一张是销售。每次销售都有一个它来自的模具,与一个模具关系有很多销售。我希望循环遍历所有模具,并在该循环中遍历所有销售,并在输出之前将每个行与一组标准进行比较。

'All dies have a type and a size. All products have a type and a size. We hope to match them.
Sub searchroute()
Dim x As Integer, y As Integer, z As Integer
x = 0 'for row offset on dies, number
y = 0 'for row offset on sales, item
z = 0 'for later use

Do Until IsEmpty(Worksheets("Dies").a2.Offset(x, 0)) = True
    Do Until IsEmpty(Worksheets("Sales").a2.Offset(y, 0)) = True
        If Worksheets("Dies").i2.Offset(x, 0) = Worksheets("Sales").c2.Offset(y, 0) Or Worksheets("Dies").i2.Offset(x, 0) = "Any" Then
            If Worksheets("Sales").g2.Offset(y, 0) = Worksheets("Dies").j2.Offset(x, 0) Or Worksheets("Dies").j2.Offset(x, 0) = "Any" Then
                'then we've got the same type and size, print output to a cell
                'should figure out how to append, place the whole list in a single cell
            End If
        End If
        y = y + 1
    Loop
    x = x + 1
Loop

End Sub

单步执行此操作,会在第一个Do Until上弹出438错误。我知道这很容易,但我的想法是空白的。

提前感谢智慧!

1 个答案:

答案 0 :(得分:3)

Worksheets("Dies").a2.替换为Worksheets("Dies").Range("a2").

对于您尝试引用特定单元格的所有实例也是如此。