In the userform's code-module:
Dim Labels() As New LblClass
Private Sub UserForm_Initialize()
Dim LabelCount As Long
Dim ctl As Control
' Create the Label objects
LabelCount = 0
For Each ctl In Controls
If TypeName(ctl) = "Label" Then
LabelCount = LabelCount + 1
ReDim Preserve Labels(1 To LabelCount)
Set Labels(LabelCount).LabelGroup = ctl
End If
Next ctl
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
For Each lbl In Labels
With lbl.LabelGroup
.ForeColor = vbBlack
.SpecialEffect = 0
.BackStyle = 0
End With
Next lbl
End Sub
Create a new Class Module, change its name to
LblClass
and paste this code in it:
Public WithEvents LabelGroup As MsForms.Label
Private Sub LabelGroup_Click() 'you don't need this sub but it serves as an example
Msg = "You clicked " & LabelGroup.Name & vbCrLf & vbCrLf
Msg = Msg & "Caption: " & LabelGroup.Caption & vbCrLf
Msg = Msg & "Left Position: " & LabelGroup.Left & vbCrLf
Msg = Msg & "Top Position: " & LabelGroup.Top
MsgBox Msg, vbInformation, LabelGroup.Name
End Sub
Private Sub LabelGroup_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
LabelGroup.ForeColor = vbWhite
LabelGroup.SpecialEffect = 1
LabelGroup.BackStyle = 1
LabelGroup.BackColor = &H808000
End Sub
Adapted from John Walkenbach's code in Excel 20nn Power Programming with VBA, where nn is one of 02, 03, 07, 10.
All above in the attachment.