Hello,
I would like to have multiple toggle buttons in excel that are independent of each other. I created two toggle buttons with the following code and get a Run-time error '1004:
Method 'OLEOBjects' of object'_Worksheet' failed. How can this be fixed?
Private Sub ToggleButton1_Click()
Range("D42").Value = IIf(Me.OLEObjects(1).Object.Caption = "Off", 0.01, 0.03)
Me.OLEObjects(1).Object.Caption = IIf(Range("D42").Value = 0.01, "On", "Off")
End Sub
Private Sub ToggleButton2_Click()
Range("D43").Value = IIf(Me.OLEObjects(1).Object.Caption = "Off", 0.01, 0.03)
Me.OLEObjects(1).Object.Caption = IIf(Range("D43").Value = 0.01, "On", "Off")
End Sub
I would like to have multiple toggle buttons in excel that are independent of each other. I created two toggle buttons with the following code and get a Run-time error '1004:
Method 'OLEOBjects' of object'_Worksheet' failed. How can this be fixed?
Private Sub ToggleButton1_Click()
Range("D42").Value = IIf(Me.OLEObjects(1).Object.Caption = "Off", 0.01, 0.03)
Me.OLEObjects(1).Object.Caption = IIf(Range("D42").Value = 0.01, "On", "Off")
End Sub
Private Sub ToggleButton2_Click()
Range("D43").Value = IIf(Me.OLEObjects(1).Object.Caption = "Off", 0.01, 0.03)
Me.OLEObjects(1).Object.Caption = IIf(Range("D43").Value = 0.01, "On", "Off")
End Sub