Se utilizzi spesso i commenti nei tuoi fogli di lavoro, potresti chiederti se esiste un modo per stampare i commenti, ma senza il nome e i due punti che normalmente precedono ogni commento. Sfortunatamente, non esiste un modo integrato per eseguire questa operazione in Excel. Tuttavia, è possibile utilizzare una macro per estrarre rapidamente tutti i commenti da tutti i fogli di lavoro e inserirli in un nuovo foglio di lavoro. Questo foglio di lavoro potrebbe poi essere stampato, poiché equivarrebbe a un compendio di tutti i commenti. La macro è la seguente:
Public Sub RecordComments()
'Elenca i commenti legacy non in thread (Note) nel foglio di lavoro Commenti
Dim n As Integer, i As Integer, c As Comment, s As String
Dim MyWS As Worksheet, w As Worksheet
Const MyWS_Name As String = "Commenti"
On Error Resume Next
Set MyWS = Worksheets(MyWS_Name)
If Err Then
Err.Clear
Set MyWS = Worksheets.Add(After:=Sheets(Sheets.Count))
If Err Then MsgBox Err.Description, vbCritical: Exit Sub
MyWS.Name = MyWS_Name
End If
On Error GoTo 0
n = 1 'riga di intestazione
With MyWS
.Cells(1).CurrentRegion.Clear
.Cells(n, 1).Value = "Foglio di lavoro"
.Cells(n, 2).Value = "Cella"
.Cells(n, 3).Value = "Autore"
.Cells(n, 4).Value = "Commento"
For Each w In Worksheets
For Each c In w.Comments
n = n + 1
.Cells(n, 1).Value = w.Name
.Cells(n, 2).Value = c.Parent.Address
s = c.Author
.Cells(n, 3).Value = s
i = Len(s) + 2
If Left(c.Text, i) <> (s & ":" & vbLf) Then i = 0
.Cells(n, 4).Value = Mid(c.Text, (i + 1))
Next c
Next w
With .Cells(1).CurrentRegion
.Columns.VerticalAlignment = xlTop
.Columns.ColumnWidth = 120
.Columns.AutoFit
.Rows.AutoFit
End With
End With
Set MyWS = Nothing
Set w = Nothing
End Sub