2013-04-05 47 views
0

我想這樣做,如果複選框82未選中,那麼單元格J39留空,但如果它被檢查的值是3.8。上線「Sheet.Range(」 J39「)。PasteSpecial的粘貼=‘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 

如何以更好的方式執行此功能的任何想法也會begreatly讚賞

回答

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 
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