
Option Explicit
Dim x As Byte
Dim n As Integer
Sub AddComments()
' n= Numero righe
n = 15
Columns("D:D").ClearComments
For x = 11 To n
Range("D" & x).AddComment
Range("D" & x).Comment.Visible = False
Range("D" & x).Comment.Text Text:=Range("a" & x) & Chr(10)
Next x
End Sub
|
Sub add_comments()
Dim cell As Range, s As String, i As Integer
For Each cell In Range("D11:W11")
s = ""
If Not (cell.Comment Is Nothing) Then cell.Comment.Delete
For i = 1 To 3
s = s & cell.Offset(i) & Chr(10)
Next
If Trim(Replace(s, Chr(10), "")) <> "" Then
With cell.AddComment
.Visible = False
.Text s
End With
End If
Next
End Sub |
Option Explicit
Sub add_comments()
Dim last_row As Long, nominativo As Range
Dim cell As Range, s As String
last_row = Cells(Columns(1).Cells.Count, 1).End(xlUp).Row
For Each nominativo In Range("A11:A" & last_row)
If Trim(nominativo) <> "" Then
For Each cell In Range(Cells(nominativo.Row, "D"), Cells(nominativo.Row, "W"))
s = ""
If Not IsError(cell) Then
If Not (cell.Comment Is Nothing) Then cell.Comment.Delete
s = s & cell.Offset(1) & " - " & cell.Offset(2) & " " & cell.Offset(3)
If Trim(s) <> "" Then
With cell.AddComment
.Visible = False
.Text s
End With
End If
End If
Next
End If
Next
End Sub
|
