Excel怎么用VBA批量插入复选框

如题所述

1:在第一个单元格插入复选框后拖动复制。
2:如果单元格区域不规则可以用下面代码:
Private Sub AddCheckBoxesInRange()
On Error Resume Next
Dim cell As Range
Dim CurrentRange As Range

Set CurrentRange = Selection
CurrentRange.NumberFormatLocal = ";;;"
Application.ScreenUpdating = False
For Each cell In CurrentRange
ActiveSheet.CheckBoxes.Add(cell.Left, cell.Top, cell.Height, cell.Height).Select
With Selection
.Value = xlOff
.LinkedCell = cell.Address
.Display3DShading = False
.Characters.Text = ""
End With
Next
CurrentRange.Select
Application.ScreenUpdating = True

Set cell = Nothing

End Sub
温馨提示:答案为网友推荐,仅供参考