vba - 使用 VBA 在 Excel 中添加注释

标签 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 错误,说“应用程序或对象错误”(这是翻译的,原始消息:“Anwendungs-oder objektdefinierter Fehler”)

子被称为使用
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

关于vba - 使用 VBA 在 Excel 中添加注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28494788/

相关文章:

vba - Excel VBA中的列类型转换

excel - AJAX 加载更多是否会中断 VBA 网页抓取?

android-studio - Android Studio 中可用的所有评论标签是什么?

java - 当用户按下“提交”按钮时如何保存用户的评分和评论?

java - 从用户眼中隐藏 HTML 代码的最简单方法是什么?

excel - 匹配一个数字 >= A 列和 < B 列返回 C 列#

excel - VB/VBA : Fetch HTML string from clipboard (copied via web browser)

c# - 如何在 C# 中将 Excel 单元格的值类型设置为文本?

excel - VLOOKUP 单元格中的每个单词以执行缩写解码

vba - 如何根据单元格值在excel中将行从一个表复制到另一个表