Label back color change when double click.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,110
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
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
6,710
Office Version
  1. 365
Platform
  1. Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,133
Office Version
  1. 365
Platform
  1. Windows
You're code works for me, in what way isn't it working for you?
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,307
Office Version
  1. 2010
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
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
 

Watch MrExcel Video

Forum statistics

Threads
1,108,704
Messages
5,524,416
Members
409,576
Latest member
az168

This Week's Hot Topics

Top