【发布时间】:2019-03-07 21:16:20
【问题描述】:
我有一个单元格,我想放置一个 If 函数。如果所选单元格范围的平均值> = 2,if函数将显示1,否则为0。我想做一个vba,要求您选择范围组,然后将公式放在单元格上,不是价值。这样,如果所选单元格组的平均值发生变化,更新后的单元格也会发生变化。我试过这样做,但最终出现#value 错误。任何帮助表示赞赏
Sub update()
Dim siteRange As Range
ActiveCell.Select
If MsgBox("Would you like to update?", vbYesNo, "Update") = vbYes Then
Set siteRange = Application.InputBox("Select a range with the " & _
"appropraite sites.", "Sites", Type:=8)
ActiveCell.Value = "=If(Average(siteRange)>=2,1,0)"
Else
End If
End Sub
【问题讨论】:
-
Excel 对
siteRangeVBA 变量一无所知,这就是原因。