在VBA中向单元格添加注释

时间:2016-03-31 14:42:47

标签: excel vba comments ms-office office365

这是给我错误的微小宏:

错误:Application Defined or Object Defined Error

根据MatMug的建议,这是完整的代码:

Sub insertTodayDate()
    Dim cellD3 As Range
    Dim helpComment As String    
    Set cellD3 = Range("D3")
    cellD3.FormulaR1C1 = "=Today()"
    cellD3.Copy
    cellD3.PasteSpecial (xlPasteValues)
    Application.CutCopyMode = False
    cellD3.Select
    helpComment = "hello"
    Call addCustomComment(helpComment)
    Range("D4").Select
End Sub

Sub addCustomComment(text)
    Dim wksProforma As Worksheet
    Dim dateRange As Range
    Set wksProforma = Worksheets("Proforma")
    Set dateRange = wksProforma.Range("D3")
    dateRange.AddComment "text"
End Sub

为什么最后一行dateRange.AddComment(text)无效?

由于

0 个答案:

没有答案