簡體   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