我試圖自動化複選框生成。如果有人在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