gpt4 book ai didi

excel - 类型不匹配 : Range Formula

转载 作者:行者123 更新时间:2023-12-04 21:49:29 24 4
gpt4 key购买 nike

我完全不知道为什么会出现“类型不匹配”错误。

错误出现在 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

我查看了 locals 窗口,startAddy、endAddy 和 RelAddy 都是 Variant/String 类型。任何帮助将不胜感激,谢谢。

最佳答案

问题出在 Range("B2").Formula = "=COUNTA(" & Sheets("Today").Range(startAddy, endAddy) & ")"
试试 Range("B2").Formula = "=COUNTA(" & Sheets("Today").Range(startAddy, endAddy).Address & ")"
为了使用公式,您需要获取范围的地址,而不仅仅是范围

关于excel - 类型不匹配 : Range Formula,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57500118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com