Sub VesselComments1()
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
Dim Vessel_Number As Integer
MaxNumber =[b] 300[/b]
Sheets("mapview").Activate
'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("sparePivot").Cells(j, 1).Value = Sheets("mapview").Cells(1 + 2 * i, 12 * k + [b]2[/b]).Value Then
'Count the rows that are for the same "From_blk"
Vessel_Number = 1
For l = j + 1 To j + 20
If Sheets("sparePivot").Cells(l, 1).Value = Sheets("sparePivot").Cells(j, 1).Value & " Total" Then Vessel_Number = l - j
Next l
CommentText = ""
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 2).ClearComments
For l = 0 To Vessel_Number - 1
If Not Sheets("sparePivot").Cells(j + l, k + 3).Value = Empty Then
CommentText = CommentText & Sheets("sparePivot").Cells(j + l, 2).Value & Chr(10)
End If
Next l
If Not CommentText = "" Then
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 2).AddComment
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 2).Comment.Visible = False
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 2).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("sparePivot").Cells(j, 1).Value = Sheets("mapview").Cells(1 + 2 * i, 12 * k + [b]6[/b]).Value Then
'Count the rows that are for the same "From_blk"
Vessel_Number = 1
For l = j + 1 To j + 20
If Sheets("sparePivot").Cells(l, 1).Value = Sheets("sparePivot").Cells(j, 1).Value & " Total" Then Vessel_Number = l - j
Next l
CommentText = ""
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 6).ClearComments
For l = 0 To Vessel_Number - 1
If Not Sheets("sparePivot").Cells(j + l, k + 3).Value = Empty Then
CommentText = CommentText & Sheets("sparePivot").Cells(j + l, 2).Value & Chr(10)
End If
Next l
If Not CommentText = "" Then
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 6).AddComment
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 6).Comment.Visible = False
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 6).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("sparePivot").Cells(j, 1).Value = Sheets("mapview").Cells(1 + 2 * i, 12 * k + [b]10[/b]).Value Then
'Count the rows that are for the same "From_blk"
Vessel_Number = 1
For l = j + 1 To j + 20
If Sheets("sparePivot").Cells(l, 1).Value = Sheets("sparePivot").Cells(j, 1).Value & " Total" Then Vessel_Number = l - j
Next l
CommentText = ""
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 10).ClearComments
For l = 0 To Vessel_Number - 1
If Not Sheets("sparePivot").Cells(j + l, k + 3).Value = Empty Then
CommentText = CommentText & Sheets("sparePivot").Cells(j + l, 2).Value & Chr(10)
End If
Next l
If Not CommentText = "" Then
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 10).AddComment
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 10).Comment.Visible = False
Sheets("mapview").Cells(2 + 2 * i, 12 * k + 10).Comment.Text Text:=CommentText
End If
End If
Next j
Next i
Next k
End Sub