[英]Adding a comment to cell by VBA based on cell value then remove it on value change
[英]Move from comment to cell and remove
這將起作用:將代碼添加到模塊,選擇要更改的單元格,運行代碼。
Sub Move_To_Comment_And_Clear_Comment()
Dim CL As Range
Dim RG As Range
Dim Commenttext As String
Set RG = Selection
If RG.Cells.Count > 200 Then
If MsgBox("You have selected more than the recommended range size of 200 cells." & vbCrLf & vbCrLf & _
"Total Cells Selected = " & RG.Cells.Count & vbCrLf & vbCrLf & _
"Are you SURE you want to run this? It could take a considerable amount of time or freeze your workbook.", _
vbYesNo, "WARNING") = vbNo Then Exit Sub
End If
For Each CL In RG.Cells
If Not CL.Comment Is Nothing Then
Commenttext = CL.Comment.Text
With CL
CL.Value = Mid(Commenttext, InStr(1, Commenttext, Chr(10), vbTextCompare) + 1, Len(Commenttext))
CL.ClearComments
End With
End If
Next CL
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.