繁体   English   中英

为什么我得到Object Required错误(VBA,Excel)

[英]Why am I getting Object Required error (VBA, Excel)

为什么以下代码有误?

Sub SetFont()
    Dim a1 As Range
    Set a1 = Range("a1")
    SetFontSize (a1)
End Sub

Sub SetFontSize(target As Range)
    target.Font.Size = 11
End Sub

调用SetFontSize方法时出现“运行时错误424:对象需要”错误。

你没有调用函数,调用SetFontSize (a1)时不需要括号。

只需使用:

SetFontSize a1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM