Sub DisplayTTId()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim Name As String
Dim Period As Integer
Dim BlkName As String
Dim MaxNumber As Integer
Dim CommentText As String
MaxNumber = 100
'for Periods 0 to 8
For k = 0 To 8
'First block of alphanumerics (15 Values)
For i = 1 To 15
For j = 3 To MaxNumber
If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 2).Value Then
'Count the rows that are for the same "From_blk"
TTID_Number = 1
For l = j + 1 To j + 20
If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
Next l
CommentText = ""
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).ClearComments
For l = 0 To TTID_Number - 1
If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
End If
Next l
If Not CommentText = "" Then
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).AddComment
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Visible = False
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 1).Comment.Text Text:=CommentText
End If
End If
Next j
Next i
'Second block of alphanumerics (15 Values)
For i = 1 To 15
For j = 3 To MaxNumber
If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 6).Value Then
'Count the rows that are for the same "From_blk"
TTID_Number = 1
For l = j + 1 To j + 20
If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
Next l
CommentText = ""
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).ClearComments
For l = 0 To TTID_Number - 1
If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
End If
Next l
If Not CommentText = "" Then
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).AddComment
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).Comment.Visible = False
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 5).Comment.Text Text:=CommentText
End If
End If
Next j
Next i
'Third block of alphanumerics (8 Values)
For i = 1 To 8
For j = 3 To MaxNumber
If Sheets("Sheet1").Cells(j, 1).Value = Sheets("Sheet2").Cells(1 + 2 * i, 12 * k + 10).Value Then
'Count the rows that are for the same "From_blk"
TTID_Number = 1
For l = j + 1 To j + 20
If Sheets("Sheet1").Cells(l, 1).Value = Sheets("Sheet1").Cells(j, 1).Value & " Total" Then TTID_Number = l - j
Next l
CommentText = ""
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).ClearComments
For l = 0 To TTID_Number - 1
If Not Sheets("Sheet1").Cells(j + l, Period + 3).Value = Empty Then
CommentText = CommentText & Sheets("Sheet1").Cells(j + l, 2).Value & Chr(10)
End If
Next l
If Not CommentText = "" Then
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).AddComment
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).Comment.Visible = False
Sheets("Sheet2").Cells(2 + 2 * i, 12 * k + 9).Comment.Text Text:=CommentText
End If
End If
Next j
Next i
Next k
End Sub