【发布时间】:2016-06-07 21:49:07
【问题描述】:
我正在尝试自动生成复选框。如果有人在 C10 或更低的单元格中单击并写入内容,例如 C11、C12...,那么单元格的右侧应该会出现一个复选框。
它应该看起来像这样:
我应该怎么做?
更新!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim chkbox As CheckBox
If Not (Intersect(Target, Range("C10:C1000")) Is Nothing) Then
If Not (IsEmpty(Target.Cells.Value)) Then
'If the cell is NOT empy, I should add a checkbox, to the right of the cell without text
Set chkbox = ActiveSheet.CheckBoxes.Add(Target.Left, Target.Top, Target.Width, Target.Height)
With chkbox
.Text = ""
End With
Else
For Each chkbox In ActiveSheet.CheckBoxes
If Not Intersect(Target, chkbox.TopLeftCell) Is Nothing Then
chkbox.Delete
End If
Next chkbox
End If
End If
End Sub
【问题讨论】:
-
到目前为止你有什么尝试?任何vba代码?谢谢
-
我唯一的问题是,如果我想删除多个单元格,复选框删除无法正常工作。