簡體   English   中英

從評論移動到單元格並刪除

[英]Move from comment to cell and remove

我想從評論移動到單元格並通過 VBA 刪除“Alvise Tran:” 顯示的結果將類似於單元格 H3、H7、H11

在此處輸入圖像描述 謝謝

這將起作用:將代碼添加到模塊,選擇要更改的單元格,運行代碼。

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM