A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Please unmark my previous reply - it doesn't solve your problem. Perhaps this one will.
Class module:
Option Explicit
Public WithEvents ALabel As MSForms.Label
Public WithEvents BImage As MSForms.Image
Public WithEvents UForm As MSForms.UserForm
Private Sub ALabel_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ControlColorChange ALabel
End Sub
Private Sub BImage_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ControlColorChange BImage
End Sub
Private Sub UForm_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
RestoreControlColours UForm
End Sub
Standard module:
Option Explicit
Public cls() As New clsEvent ' Replace with the name of your class module
Sub ControlColorChange(ctrl As MSForms.Control)
If TypeName(ctrl) = "Label" And ctrl.Tag = "?" Then
ctrl.ForeColor = &H80FF&
ctrl.Font.Size = 9
ctrl.Font.Bold = True
End If
If TypeName(ctrl) = "Image" And ctrl.Tag = "*" Then
ctrl.BorderColor = &H80FF&
End If
End Sub
Sub RestoreControlColours(UsForm As MSForms.UserForm)
Dim ctrl As MSForms.Control
For Each ctrl In UsForm.Controls
If TypeName(ctrl) = "Label" And ctrl.Tag = "?" Then
ctrl.ForeColor = &HA76C42
ctrl.Font.Size = 8
ctrl.Font.Bold = False
End If
If TypeName(ctrl) = "Image" And ctrl.Tag = "*" Then
ctrl.BorderColor = &HF5EFEA
End If
Next ctrl
End Sub
Sub ShowForm()
Dim n As Long
Dim ctrl As MSForms.Control
For Each ctrl In UserForm1.Controls
If TypeName(ctrl) = "Label" And ctrl.Tag = "?" Then
n = n + 1
ReDim Preserve cls(1 To n)
Set cls(n).ALabel = ctrl
End If
If TypeName(ctrl) = "Image" And ctrl.Tag = "*" Then
n = n + 1
ReDim Preserve cls(1 To n)
Set cls(n).BImage = ctrl
End If
Next ctrl
n = n + 1
ReDim Preserve cls(1 To n)
Set cls(n).UForm = UserForm1
UserForm1.Show
End Sub
Change clsEvents to the name of the class module and UserForm1 to the name of the userform.