次のコードがあります。
For rowIndex = rowOffset To 15
Dim currentDate As Date
Dim nextRowDate As Date
currentDate = Cells(rowOffset, colIndex).Value
nextRowDate = Cells(rowIndex + 1, colIndex).Value
Dim currentYear As Date
currentYear = DatePart("yyyy", currentDate)
Dim nextYear As Date
nextYear = DatePart("yyyy", nextRowDate)
If currentYear <> nextYear Then
Call RenderYearStyle(rowIndex, colIndex)
Else
Call ClearStyle(rowIndex, colIndex)
End If
Next rowIndex
日付部分または「年」関数は、日付の年の部分を返しません。何か案は?