LoginSignup
0
1

More than 3 years have passed since last update.

エクセル勤怠、VBAで土・日を〇で囲う作業を自動化させた

Last updated at Posted at 2020-11-22

過去に使っていた勤務表作成の中でめんどくさい作業があったので
VBAを作り、一部作業を自動化しました。今は別の勤務管理システム
へと移行したので現在は使ってはいないのですが、過去の産物として
NETに公開しようと思います。

1.PNG

このようにエクセル上に直接手入力で出勤時間と退勤時間を入力します。

毎月の曜日が土、日である場合丸を付けないといけないのですが、毎月日付と曜日が違い
一個一個ずらすのが煩わしかったのでマクロを作り、自動化しました。

以下がそのコードです。

Sub donichi()
Dim n As Long
n = 10
For i = 9 To 39
    If Cells(i, n) = "土" Then
        With Cells(i, n)
            With ActiveSheet.Shapes.AddShape(msoShapeOval, .Left, .Top, 18, .Height)
            .Fill.Visible = False
            .Line.ForeColor.RGB = RGB(0, 0, 0)
            .Line.Weight = 1
            End With
        End With
    End If
    If Cells(i, n) = "日" Then
        With Cells(i, n)
            With ActiveSheet.Shapes.AddShape(msoShapeOval, .Left, .Top, 18, .Height)
            .Fill.Visible = False
            .Line.ForeColor.RGB = RGB(0, 0, 0)
            .Line.Weight = 1
            End With
          End With
    End If
Next
End Sub

これを実行するとこうなります。↓

2.PNG

何かのお役に立てれば幸いです。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1