我试图这样做,如果未选中复选框82,则单元格J39保留为空白但如果选中它则值为3.8。在“Sheet.Range(”J39“)。PasteSpecial Paste =”3.8“”我收到错误消息1004
Sub ChckBx_Deisel_Engines()
Dim Sheet As Worksheet: Set Sheet = ThisWorkbook.Worksheets("NSR FORM")
If Sheet.Shapes("Check Box 82").ControlFormat.Value = 0 Then
Sheet.Range("J39").PasteSpecial Paste = ""
End
ElseIf Sheet.Shapes("Check Box 82").ControlFormat.Value = 1 Then
Sheet.Range("J39").PasteSpecial Paste = "3.8"
End If
End Sub
任何有关如何以更好的方式执行此功能的想法也会受到赞赏
答案 0 :(得分:1)
想出来!这是我改变它以使该功能起作用的代码
Sub Button82_Click()
If ThisWorkbook.Worksheets("NSR FORM").Shapes("Check Box 82").OLEFormat.Object.Value = 1 Then
Range("J39").Value = "3.8"
Else
Range("J39").Value = ""
End If
End Sub
答案 1 :(得分:0)
Dim Sheet As Worksheet: Set Sheet = ThisWorkbook.Worksheets("NSR FORM")
If Sheet.Shapes("Check Box 82").ControlFormat.Value = 0 Then
Sheet.Range("J39").PasteSpecial Paste = "" :Exit sub <<< to exit direct from your project
ElseIf Sheet.Shapes("Check Box 82").ControlFormat.Value = 1 Then
Sheet.Range("J39").PasteSpecial Paste = "3.8"
End If
End Sub