Label back color change when double click.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,280
Office Version
  1. 2013
Platform
  1. Windows
Hello,
Can I get help with the code given below.
I'm trying to change back color of label.:)
Thanks..


Code:
Private Sub Label1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

    With Application
    Me.Label1.BackColor = 15773696
    End With


End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Your code works for both..
- a label on a userform
- an active-x label on a worksheet

The code needs to be in the userform or sheet module as relevant
 
Upvote 0
You're code works for me, in what way isn't it working for you?
 
Upvote 0
Hello,
Can I get help with the code given below.
I'm trying to change back color of label.:)
Thanks..
Code:
Private Sub Label1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    With Application
    Me.Label1.BackColor = 15773696
    End With
End Sub
As others have said, the code you posted works fine. Actually, the With..EndWith statements and Me qualifier are not needed as this works the same way...
Code:
Private Sub Label1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
  Label1.BackColor = 15773696
End Sub
As to your problem... is it that you wanted the code to toggle the color on and off as you repeatedly double clicked the Label? If so, give this code a try...
Code:
Private Sub Label1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
  If Label1.BackColor = -2147483633 Then
    Label1.BackColor = 15773696
  Else
    Label1.BackColor = -2147483633
  End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,957
Latest member
Hat4Life

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