【发布时间】:2018-08-16 11:18:25
【问题描述】:
我有个看似简单的目标,就是把B列的内容变成A列的cmets。
我曾尝试使用@Dy.Lee 中提到的here 的以下代码,但不幸的是它给了我一个运行时错误“1004”应用程序定义或对象定义错误...
Sub Komentari()
Dim rngDB As Range, rngComent As Range
Dim rng As Range
Dim cm As Comment, i As Integer
Set rngComent = Range("A1:A50")
Set rngDB = Range("B1:B50")
For Each rng In rngComent
i = i + 1
If Not rng.Comment Is Nothing Then
rng.Comment.Delete
End If
Set cm = rng.AddComment
With cm
.Visible = False
.Text Text:=rngDB(i).value
End With
Next rng
End Sub
请有人指出错误或为此提出更好的解决方案吗?
【问题讨论】:
-
错误在哪一行?
-
试试
.Text Text:=rngDB(i).text以确保它是一个字符串? -
@QHarr - 错误出现在 .Text Text:=rngDB(i).value