Banner

Wednesday, March 8, 2017

How Can Use Togglebutton InUserform Excell VBA





Private Sub ToggleButton1_Click()

On Error Resume Next

For i = 1 To 5000

If Me.ToggleButton1.Value = True Then

Me.ToggleButton1.Caption = "OFF"

Me.ToggleButton1.BackColor = vbRed

Else

Me.ToggleButton1.Caption = "ON"

Me.ToggleButton1.BackColor = vbGreen

End If

If Me.TextBox1.Text <= 4999 And Me.ToggleButton1.Caption = "OFF" Then

Me.TextBox1.Text = Me.TextBox1.Text + 1

DoEvents

End If

Next i

Me.ToggleButton1.Caption = "ON"

Me.ToggleButton1.Value = False

End Sub

No comments:

Post a Comment

Please do not enter any spam message in comment box