excel room

事務作業で役に立つエクセル関数などを解説します。

チェックボックスの自動作成マクロ

Sub macro()
    Dim checkList As Object
    Dim i As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")
    
    For i = 2 To ws.Cells(Rows.Count, 2).End(xlUp).Row
    If ws.Cells(i, 1) = "" Then
    With ws.Cells(i, 1)
    
    ActiveSheet.CheckBoxes.Add(.Left, .Top, .Width, .Height).Select
    
    With Selection
    .LinkedCell = ws.Cells(i, 1).Address
    .Text = ""
    End With
    
    .Font.Color = rgbWhite
    End With
    
    ws.Cells(i, 1) = False
    
    End If
    
    Next
    
End Sub