Flickering Labels on Mouse Over

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,057
Office Version
  1. 2016
Platform
  1. Windows
Hi

I am having an issue with flickering labels on userform, when i do a mouse over. Apart from the flicker they work fine. . I am using labels as buttons as the look better than the vba userform buttons and because, when I tried to you an image as a button, the picture would not display correct, the quality would reduce, but it was fine in a label.

The labels start to flicker when I move the mouse over them, I was looking at this, Mr Excel, but I am not 100% sure how to change it for my labels. Please could someone advise.

VBA Code:
Private Sub MainMenuPageButton_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'MainMenuPageButton border change green on mouse over
     MainMenuPageButton.BorderColor = 8435998
            'Grey Borders for all other labels
             SearchButton.BorderColor = -2147483627
             WebBrowserButton.BorderColor = -2147483627
             SaveFileButton.BorderColor = -2147483627
            EmailButton.BorderColor = -2147483627
            LoadFileButton.BorderColor = -2147483627
            Sheet2Button.BorderColor = -2147483627
            Sheet3Button.BorderColor = -2147483627
           Sheet12Button.BorderColor = -2147483627
End Sub
1586869826282.png

Thanks in advance.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,057
Office Version
  1. 2016
Platform
  1. Windows
Hi

I have found this on the forum as another possible option link may need modifications, but I am not too sure what they mean by grouping and label group, could some please advise. And also where this code needs to be pasted, is it in the userform or in the labels?

I have listed the code from the link below, it was done by MickG

VBA Code:
Option Explicit
Public WithEvents LabelGroup As MSForms.Label

Private Sub LabelGroup_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim Ctrl As MSForms.Control

For Each Ctrl In LabelGroup.Parent.Parent.Controls
  DoEvents
   If X > 5 And X < Ctrl.Width - 5 Then
      If TypeName(Ctrl) = "Label" Then
        If Ctrl.name = LabelGroup.name Then
            Ctrl.BackColor = &H808000
        Else
            Ctrl.BackColor = LabelGroup.Parent.Parent.BackColor
        End If
      End If
    End If
Next Ctrl
End Sub
 

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,057
Office Version
  1. 2016
Platform
  1. Windows
Hi

Can some one please help me on this as I am still stick on the flickering. I have REPLACED the labels with images now and improved their quality, however I still can not get rid on the screen flickering on mouse over event. I think the above code from MickG might work but I am not sure of this "LabelGroup.Parent.Parent.Controls"

I have slightly changed the code to an IF statement

VBA Code:
Private Sub MainMenuPageButton_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'MainMenuPageButton border change green on mouse over

If MainMenuPageButton.BorderColor <> 8435998 Then
     MainMenuPageButton.BorderColor = 8435998
           
 'Grey Borders for all other labels
             SearchButton.BorderColor = -2147483627
             WebBrowserButton.BorderColor = -2147483627
             SaveFileButton.BorderColor = -2147483627
            EmailButton.BorderColor = -2147483627
            LoadFileButton.BorderColor = -2147483627
            Sheet2Button.BorderColor = -2147483627
            Sheet3Button.BorderColor = -2147483627
           Sheet12Button.BorderColor = -2147483627
End if
End Sub
 

Forum statistics

Threads
1,144,694
Messages
5,725,803
Members
422,640
Latest member
KazPL

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
Top