カテゴリー
excell macro

04_determination of a holiday

today’s theme is holiday judgement by excell macro.

I think holiday doesn’t have cycle.
some enterprises has a special holiday.
it is anniversary of founding, and so on.

After some thought,
I decided coding holidays judgement per day.

bellow is macro statement of holiday judgement.

ーーーーーーーーーーーーーーーーーーーーーー
Dim D_num As Date
Dim myData(9) As String
Dim i As Integer

myData(0) = “”
myData(1) = #12/30/2020#
myData(2) = #12/31/2020#
myData(3) = “”
myData(4) = “”
myData(5) = “”
myData(6) = “New Year’s Holiday”
myData(7) = “New Year’s Holiday”
myData(8) = “”
myData(9) = “”

For i = LBound(myData) To UBound(myData)

Dim F_num As Long
For F_num = 1 To 10

D_num = CDate(Cells(F_num, 1))
’assume that there are day of 10 cells from left corner to downward direction
’and format of these cells is day form without asterisk.
’(not *3/14/2012, but 2012/3/14)

If InStr(myData(i), D_num) <> 0 Then
Cells(F_num, 1).Font.ColorIndex = 46
’if the cell matched holiday change the character color.
Cells(F_num, 2) = myData(i + 5)
’and writing holiday name next to this.

Exit For
End If
Next F_num
Next i
ーーーーーーーーーーーーーーーーーーーーーー

i used one-dimensional matrix as two-dimensional
by IF sentence.

thank you.

「04_determination of a holiday」への1件の返信

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です