我试图自动化复选框生成。如果有人在C10单元格中点击或写入某些内容,或者像C11,C12 ...那样,则单元格右侧应显示一个复选框。自动复选框生成Excel VBA
它应该是这个样子:
我应该怎么办呢?
UPDATE!:
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代码?谢谢 –
我加了代码:) – Twi
我唯一的问题是,如果我想删除多个单元格,checbox删除工作不正常。 – Twi