Thanks to all the help from our members, I'm really close to having this code nailed down. I have a large calendar used for pool planning, within the range of the cells they will have values depending on the schedule. I created an update button to press when all values need comments added to them. They are pulling data from a different sheet. All of the code works except for at the end. It is highlighting If arr(i, j) = cell.Value Then
And not removing comments where cells no longer have values. I think the issue is with the last row/col call out but after looking through the forums I don't have the technical skills to use what I found to resolve my issue. Found this Error in finding last used cell in VBA - seems useful.
Private Sub Update_Click()
Dim arr As Variant, element As Variant
Dim i As Long, j As Long, listItems As Long, rwLast As Long, clLast As Long
Dim comm As String
Dim rng As Range, cell As Range
listItems = Sheets("list").Range("A1").End(xlDown).Row
rwLast = Cells.SpecialCells(xlCellTypeLastCell).Row ' Adjust to fit your needs
clLast = Cells.SpecialCells(xlCellTypeLastCell).Column 'Idem
Set rng = Sheets("list").Range("A1:A" & listItems)
arr = Range("D11:CY148").Value
With Worksheets("Finish Matrix")
For i = 1 To rwLast - 10 'Adjust to make it more general, this is pretty rough
For j = 1 To clLast - 3 'Idem
If i = 3 Then
End If
comm = ""
For Each cell In rng
If arr(i, j) = cell.Value Then
comm = comm & Chr(13) & cell.Offset(0, 1).Value
End If
Next cell
If Not (comm = "") Then
.Cells(10, 3).Offset(i, j).ClearComments
.Cells(10, 3).Offset(i, j).AddComment
.Cells(10, 3).Offset(i, j).Comment.Text Text:=comm
End If
Next j
Next i
End With
End Sub
Surely I am missing a minor adjustment in my code to get it squared away. I'd rather keep it a simple solution if possible. Thanks in advance.