I was playing around with a comment adding macro requested by another member
https://www.excelforum.com/excel-pro...t=#post4981390
I I decided as an exercise to try to shorten the code by working out the permutations (First attempt)
I think I have the correct controls in place for the macro to pull the data from columns 5 and 7 into the comment for the correct date but when I extend passed the first 2 rows I seem to tripping over because I must be calling in the wrong order. The furthest I've got is populating the first 4 rows with the correct data.
Would someone with more knowledge of these loops please point me in the right direction.
Sub Add Comment_Click()
Dim i, ii, iii, iiii As Integer
Dim ws As Worksheet
Dim myArr1 As Variant
'i = month days (1 to 31)
'ii = month comment 1 and comment 2 rows (4 to 28)
'iii = month days to start next month off on right row sheet 2(myArr1)
'iiii = control figure for (2*ii)-iiii to keep column number at 5 and seven - see columns sheet1(4 to 51)
myArr1 = Array(1) 'complete myArr1 = Array(1, 32, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334)
Set ws = Worksheets("Calendar Overview")
With ws
For Each iii In myArr1
For ii = 4 To 5 ' complete range 4 to 27
For iiii = 3 To 3 'complete range 3 to 47
For i = 1 To 31
On Error Resume Next
If Cells(ii, i + 2).Interior.ColorIndex = 16 Then GoTo 0
Cells(ii, i + 2).Comment.Delete
Cells(ii, i + 2).AddComment
Cells(ii, i + 2).Comment.Text Text:=Sheets("Admin 2019 Calendar").Cells(i + iii, ((2 * ii) - iiii)).Text
Cells(ii, i + 2).Comment.Shape.TextFrame.AutoSize = True
Cells(ii, i + 2).Comment.Shape.TextFrame.Characters.Font.Size = 12
0:
Next i
Next iiii
Next ii
Next
End With
End Sub
I should have spent my time working out how to fill them from probably a faster array method but this thing just got stuck in my head...
Bookmarks