我正在尝试运行代码,但面对
应用程序定义的错误/对象定义错误
就行:.Range("JI2:JM2").Formula = strFormulas
请帮我解决问题。
Sub Copy_Reason()
Dim sh As Worksheet
Dim lRow, p, q As Long
Set sh = ThisWorkbook.Sheets("Sum_Reasons")
lRow = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox lRow
Dim strFormulas(1 To 5) As Variant
With ThisWorkbook.Sheets("Sum_Reasons")
strFormulas(1) = "=IFERROR(LARGE($B2:$JH2,ROW($1:$1)),"")"
strFormulas(2) = "=IFERROR(LARGE($B2:$JH2,ROW($2:$2)),"")"
strFormulas(3) = "=IFERROR(LARGE($B2:$JH2,ROW($3:$3)),"")"
strFormulas(4) = "=IFERROR(LARGE($B2:$JH2,ROW($4:$4)),"")"
strFormulas(5) = "=IFERROR(LARGE($B2:$JH2,ROW($5:$5)),"")"
.Range("JI2:JM2").Formula = strFormulas
.Range("JI2:JM" & lRow).FillDown
End With
End Sub
答案 0 :(得分:1)
strFormulas(1) = "=IFERROR(LARGE($B2:$JH2,ROW($1:$1)),"")"
(和其他人)应该是
strFormulas(1) = "=IFERROR(LARGE($B2:$JH2,ROW($1:$1)),"""")"
你需要通过将它们加倍来逃避"
。
答案 1 :(得分:0)
核心问题并没有像其他人提到的那样逃避x2 <- c(0, 0, 1, 2, 3, 0, 1, 0, 1, 2, 0)
。
还有一些其他问题,请参阅下面的内联评论
"