我发现一些code
还不错↴
Sub Comments2cells()
Dim c As Range, n, m, r
Set c = Selection.Find("*", Selection.Cells(Selection.Cells.Count), xlComments, , xlByRows, xlNext)
If c Is Nothing Then
MsgBox "There are no comments in the selected range", vbInformation
Exit Sub
End If
On Error Resume Next
Set n = Application.InputBox("Click the column to insert", Type:=8)
If Err Then
MsgBox "The range of inserts is not selected", vbExclamation
Exit Sub
End If
n = n.Column
Do
If c.Row <> r Then r = c.Row: m = n Else m = m + 1
Cells(r, m) = c.Comment.Text
c.Comment.Delete
Set c = Selection.FindNext(c)
Loop Until c Is Nothing
End Sub
如何更改代码,以便可以:
Comment
↵(带有红色指示符)从一个单元格复制粘贴到另一个单元格,而不会在单元格本身中粘贴文本。
PS 。···上面的代码将Сomment
中的文本插入到单元格中。我不需要。
不,不,不!这不是我想要的!
我决定编辑我的问题以使其更清楚!
我共享的代码...
Comment
的单元格区域。看看21秒screencast!
Comment
,然后从单元格中删除Comment
(我不需要删除)。 Comment
中插入文本)。请帮助更正代码!
答案 0 :(得分:1)
您可以尝试:
Option Explicit
Sub test()
Dim strCom As String
With ThisWorkbook.Worksheets("Sheet1")
'Method 1
'Ger the comment from A1
strCom = .Range("A1").Comment.Text
'Import the comment in A2
.Range("A2").AddComment strCom
'Method 2
'Copy paste the comment
.Range("A1").Copy
.Range("A2").PasteSpecial xlPasteComments
End With
End Sub
答案 1 :(得分:0)
您可以尝试复制整个源单元格,然后仅将注释粘贴到目标单元格:
Sub copyComment()
Dim sht As Worksheet
Dim destRng As Range
Dim srcRng As Range
Set sht = ThisWorkbook.Worksheets("Name of your Worksheet")
Set srcRng = sht.Range("A1")
Set destRng = sht.Range("B1")
srcRng.Copy
destRng.PasteSpecial xlPasteComments
End Sub