checkbox将特定值返回给不同的单元格

我有以下代码,我认为有几个问题。 我需要它在基于CheckBox的两个单元格中input不同的值。

Sub YesNoChkBox() Dim ChkBx As CheckBox, g As Integer, h As Integer, r As Integer Set ChkBx = ActiveSheet.CheckBoxes(Application.Caller) With ChkBx.TopLeftCell r = .Row g = .Column + 2 h = .Column + 3 End With If ChkBx = 1 Then gr = "NO" hr = "NO" Else gr = "YES" hr = "" End If End Sub 

我需要checkboxinputNO,NO到两个单元格(2和3列以上),如果选中, YES,BLANK(“”),如果不选中。

我使用r,g,h的原因是因为我想复制并粘贴checkbox到不同的行,并自动填充相应的单元格(这将始终是列G:H,但行5:21)

你的意思是?

 If ChkBx = 1 Then Cells(r, g) = "NO" Cells(r, h) = "NO" Else Cells(r, g) = "YES" Cells(r, h) = "" End If