TOggle Button will not change to white.

JohnnyBQue

New Member
Joined
Apr 25, 2016
Messages
8
When I click the button if its WHITE it turns to RED if its RED it turns to WHITE the code operates correctly but when the color suppose to change back to WHITE it changes to a very very light Red, but there are times when it changes completely white.

Is this just an Excel thing ??? I really need the cell to turn completely white every time.

{Private Sub Card4_Click()
If Me.Card4.BackColor = &HFFFFFF Then
Me.Card4.BackColor = &HFF
ElseIf Me.Card4.BackColor = &HFF Then
Me.Card4.BackColor = &HFFFFFF
End If
End Sub}
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Your code works for me, but another way would be
Code:
Private Sub Card4_Click()
Me.card4.BackColor = IIf(Me.card4.BackColor = vbRed, vbWhite, vbRed)
End Sub
 
Upvote 0
Your code works for me, but another way would be
Code:
Private Sub Card4_Click()
Me.card4.BackColor = IIf(Me.card4.BackColor = vbRed, vbWhite, vbRed)
End Sub
Or, if you set the back color to either red or white at design time, then you could do this instead...
Code:
Private Sub Card4_Click()
  Me.Card4.BackColor = vbRed + vbWhite - Me.Card4.BackColor
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top