1
我一直在试图找到一个解决方案,这个错误几个小时,我不能使它的工作。代码工作之前,我汇集了第一个AND语句如果And (final.Cells(j, 4) = rawSort(m, 2)) And (final.Cells(j, 6) = rawSort(m, 3))
,如果我删除它的作品,但没有与所需的结果。VBA错误代码438'对象不支持此属性或方法'in if语句
我不知道该怎么做,任何帮助将不胜感激。
下面是函数(j是指数)
Public Function waste%(j) Set final = ActiveWorkbook.Sheets("Master file") Set rawSort = ActiveWorkbook.Sheets("Input Volume") Dim index As Integer index = rawSort.Cells(rows.Count, "A").End(xlUp).row
For m = 2 To index
If (final.Cells(j, 2) = rawSort.Cells(m, 1) And (final.Cells(j, 4) = rawSort(m, 2)) And (final.Cells(j, 6) = rawSort(m, 3))) Then
If (rawSort.Cells(m, 2) = "March" Or rawSort.Cells(m, 2) = "June" Or rawSort.Cells(m, 2) = "September" Or rawSort.Cells(m, 2) = "December") And rawSort.Cells(m - 1, 1) = rawSort.Cells(m, 1) And rawSort.Cells(m - 2, 1) = rawSort.Cells(m, 2) And m > 3 Then
final.Cells(j, 37) = final.Cells(j, 31)/(final.Cells(j, 31) + rawSort.Cells(m - 2, 10).Value + rawSort.Cells(m - 1, 10).Value + rawSort.Cells(m, 10).Value) 'local
ElseIf rawSort.Cells(m, 2).Value = "March" Or rawSort.Cells(m, 2).Value = "June" Or rawSort.Cells(m, 2).Value = "September" Or rawSort.Cells(m, 2).Value = "December" And rawSort.Cells(m - 1, 1).Value = rawSort.Cells(m, 1).Value And m > 2 Then
final.Cells(j, 37) = final.Cells(j, 31)/(final.Cells(j, 31) + rawSort.Cells(m - 1, 10).Value + rawSort.Cells(m, 10).Value) 'local
ElseIf rawSort.Cells(m, 2).Value = "March" Or rawSort.Cells(m, 2).Value = "June" Or rawSort.Cells(m, 2).Value = "September" Or rawSort.Cells(m, 2).Value = "December" And m > 1 Then
final.Cells(j, 37) = final.Cells(j, 31)/(final.Cells(j, 31) + rawSort.Cells(m, 10).Value) 'local
Else
final.Cells(j, 37) = "lel" 'error message, will be removed later
End If
Else
final.Cells(j, 37) = Null
End If
Next m
End Function
哇,我简直不敢相信我错过了...所有早上失去了,头痛得到了...非常感谢!现在,它终于可以工作了,我可以转移到另一个方面,但我仍然不明白为什么它不起作用。我有另一个,如果这是如下“如果x <> 0和x <>空”,并且即使当我有值x = 600情况不符合。我通过改变和解决了它或者但我更喜欢有一个和那里。有什么想法为什么发生这种情况? –