Hi PardySound
Not sure If I have understood your problem totally, but the attached workbook contains 2 macros.
The first will look at each of the dates, check whether they are holiday dates and colour them Yellow or Green, with a cell comment of Chinese or International.
Sub MarkDates()
Dim type1 As Long, type2 As Long
Dim rn As Long, cn As Long, i As Long, j As Long
rn = 12 ' starting row number
For j = 1 To 2 ' this would need changing to 13 for full year
For i = 3 To 33
type1 = WorksheetFunction.CountIf(Range("M37:M46"), Cells(rn, i).Value)
type2 = WorksheetFunction.CountIf(Range("M47:M50"), Cells(rn, i).Value)
If type1 > 0 Or type2 > 0 Then
Cells(rn, i).Select
Selection.ClearComments
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent4
.TintAndShade = 0.399975585192419
.PatternTintAndShade = 0
End With
Selection.AddComment
Selection.Comment.Visible = False
If type1 Then
Selection.Comment.Text Text:="Chinese" & Chr(10) & ""
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
Selection.Comment.Text Text:="InterNational" & Chr(10) & ""
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65280
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
End If
Next i
rn = rn + 13 ' number of rows between Dates
Next j
End Sub
The second Macro then finds each of the commented cells, and tests the range of entries below that date to look for the search item - "PHO".
When found, it lists the persons name, the date and the type onto a list on Sheet2.
Sub ListNames()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim myRange As Range, rgComments As Range
Dim found As String, mr As Long, mc As Long, lr As Long
Dim SearchItem As String
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set rgComments = ws1.Cells.SpecialCells(xlCellTypeComments)
SearchItem = "PHO"
For Each cell In rgComments
mr = cell.Row
mc = cell.Column
lr = ws1.Cells(mr, mc).End(xlDown).Row
Set myRange = Range(Cells(mr, mc), Cells(mr + lr - mr, mc))
If WorksheetFunction.CountIf(myRange, SearchItem) Then
found = WorksheetFunction.Match(SearchItem, myRange, 0)
lr = ws2.Cells(Rows.Count, 1).End(xlUp).Row + 1
ws2.Cells(lr, 1) = ws1.Cells(mr + found - 1, 2).Value
ws2.Cells(lr, 2) = ws1.Cells(mr, mc).Value
ws2.Cells(lr, 3).Value = "'" & ws1.Cells(mr, mc).Comment.Text
End If
Next
End Sub
Hopefully, even if this is not the format you want, there will be sufficient for you to amend to suit your requirements.
Bookmarks