Flickering Labels on Mouse Over

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
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

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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