HasFormula 属性

       

如果区域中所有单元格均包含公式,则该值为 True;如果所有单元格均不包含公式,则该值为 False;其他情况下为 NullVariant 类型,只读。

示例

本示例提示用户选定 sheet1 的区域。如果该选定区域内所有单元格均包含公式,则本示例将显示消息框。

Worksheets("Sheet1").Activate
Set rr = Application.InputBox( _
    prompt:="Select a range on this worksheet", _
    Type:=8)
If rr.HasFormula = True Then
    MsgBox "Every cell in the selection contains a formula"
End If