使用VBA向excel添加注释
我真的很难在手机上添加评论 我打电话给下面的潜艇使用VBA向excel添加注释,vba,excel,comments,Vba,Excel,Comments,我真的很难在手机上添加评论 我打电话给下面的潜艇 Sub ValidationError(row As Long, column As Integer, ErrorLine As String) Tabelle1.Cells(row, column).Interior.Color = vbYellow Tabelle1.Cells(row, column).AddComment ErrorLine End Sub 但我总是收到一个1004错误,说“应用程序或对象错误”(这是翻译的原始消息:
Sub ValidationError(row As Long, column As Integer, ErrorLine As String)
Tabelle1.Cells(row, column).Interior.Color = vbYellow
Tabelle1.Cells(row, column).AddComment ErrorLine
End Sub
但我总是收到一个1004错误,说“应用程序或对象错误”(这是翻译的原始消息:“Anwendungs-Order ObjektDefinitierter Fehler”)
这个sub被称为using
Call ValidationError(8, 9, "Text string")
我做错了什么
最好如果目标单元格不包含注释,那么代码应该可以工作。 您可以更改过程以首先清除现有注释:
Sub ValidationError(row As Long, column As Integer, ErrorLine As String)
Tabelle1.Cells(row, column).Interior.Color = vbYellow
Tabelle1.Cells(row, column).ClearComments
Tabelle1.Cells(row, column).AddComment ErrorLine
End Sub
您好,请尝试以下操作:
Tabelle1.Cells(行、列)。AddComment Text:=ErrorLine