类型不匹配:范围公式
Type Mismatch: Range Formula
我完全不知道为什么会收到 "type mismatch" 错误。
错误出现在 Range(RelAddy).Formula 行。
Sub CallingUserformAssignJC()
BeforeLastRow = Sheets("Information").Cells(Rows.Count, 19).End(xlUp).Row
Sheets("Information").Range("U2:U" & BeforeLastRow).ClearContents
LastRowAC = Sheets("Information").Cells(Rows.Count, 19).End(xlUp).Row
LastCol = Sheets("Today").Cells(1, Columns.Count).End(xlToLeft).Column
For j = 1 To LastCol
CurrLastRow = Sheets("Today").Cells(Rows.Count, j).End(xlUp).Row
startAddy = Sheets("Today").Cells(2, j + 1).Address
endAddy = Sheets("Today").Cells(CurrLastRow, j + 1).Address
RelAddy = Sheets("Today").Cells(CurrLastRow + 1, j + 1).Address
Range(RelAddy).Formula = "=COUNTA(" & Sheets("Today").Range(startAddy, endAddy) & ")"
unassignedMilestone = Sheets("Today").Cells(CurrLastRow + 1, j + 1).Value
Do While unassignedMilestone <> 0
frmAssignJC.Show
frmAssignJC.Hide
Loop
j = j + 3
Next j
End Sub
我看过localswindow,startAddy、endAddy、RelAddy都是Variant/String类型。如有任何帮助,我们将不胜感激。
问题出在Range("B2").Formula = "=COUNTA(" & Sheets("Today").Range(startAddy, endAddy) & ")"
尝试Range("B2").Formula = "=COUNTA(" & Sheets("Today").Range(startAddy, endAddy).Address & ")"
为了使用公式,您需要获取范围的地址而不仅仅是范围
我完全不知道为什么会收到 "type mismatch" 错误。
错误出现在 Range(RelAddy).Formula 行。
Sub CallingUserformAssignJC()
BeforeLastRow = Sheets("Information").Cells(Rows.Count, 19).End(xlUp).Row
Sheets("Information").Range("U2:U" & BeforeLastRow).ClearContents
LastRowAC = Sheets("Information").Cells(Rows.Count, 19).End(xlUp).Row
LastCol = Sheets("Today").Cells(1, Columns.Count).End(xlToLeft).Column
For j = 1 To LastCol
CurrLastRow = Sheets("Today").Cells(Rows.Count, j).End(xlUp).Row
startAddy = Sheets("Today").Cells(2, j + 1).Address
endAddy = Sheets("Today").Cells(CurrLastRow, j + 1).Address
RelAddy = Sheets("Today").Cells(CurrLastRow + 1, j + 1).Address
Range(RelAddy).Formula = "=COUNTA(" & Sheets("Today").Range(startAddy, endAddy) & ")"
unassignedMilestone = Sheets("Today").Cells(CurrLastRow + 1, j + 1).Value
Do While unassignedMilestone <> 0
frmAssignJC.Show
frmAssignJC.Hide
Loop
j = j + 3
Next j
End Sub
我看过localswindow,startAddy、endAddy、RelAddy都是Variant/String类型。如有任何帮助,我们将不胜感激。
问题出在Range("B2").Formula = "=COUNTA(" & Sheets("Today").Range(startAddy, endAddy) & ")"
尝试Range("B2").Formula = "=COUNTA(" & Sheets("Today").Range(startAddy, endAddy).Address & ")"
为了使用公式,您需要获取范围的地址而不仅仅是范围