私は行2のすべての関連する列を満たしている数式の配列を持っています。その後、ダイナミックな参照で範囲を埋めるコードがあります。この特定のデータセットは74行のデータを有するが、何らかの理由で毎回65行目に一見、任意の時間にVBAが異常に出る?
438 Error: 'Object doesn't support this property or method'
を受信する。
'Find last row/col variables
Dim lastRow As Long
Dim lastCol As Long
'Array variable
Dim TestFormulas() As Variant
'WS variable
Dim WS as Worksheet
lastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
lastCol = Cells.Find(What:="*", _
After:=Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
'Create Array [this is cut down significantly. There are roughly 50 formulas here. Code runs quickly, if it matters.]
TestFormulas() = Array(_
"=Sheet1!H2", "=Sheet1!B2", "=IF(Sheet1!P2=""Resiliency""")
'Fill Row 2 with formulas
With WS
For i = LBound(TestFormulas()) To UBound(TestFormulas())
.Cells(2, 1 + i).Formula = TestFormulas(i)
Next i
End With
'Copy formulas and fill down the entire range
Range("A2:" & lastCol & ":" & "2").Formula = TestFormulas
Range("A2:" & WS(1).lastCol & ":" & WS(1).lastRow).FillDown
私は、ダイナミック式で埋めるために範囲を期待しています。 `lastcol数であるかの唯一までを含む行65
438 Error: 'Object doesn't support this property or method'
'範囲(:&lastCol& "" & "2" "A2")、それは、dynmicallyことで、充填します有効な範囲アドレスではない 'A2:52:2'と連結します。 Rangeオブジェクトの中で数値列を受け入れる 'Cells()'を使う必要があります。 –
また、 '... Formula = [array of formulas]'を実行できることは確かですか?ループする必要があるかもしれません。 – BruceWayne