Good morning everyone,
Before I post the actual question, I think its worthwhile letting you all know that I am only just learning about VBA coding, so my knowledge is very basic. Most of what I have learnt is from recording macros and then converting it to VBA coding and then tidying it up. Plus coding that I have gathered from google searches.
Yet the one thing, I am trying to do is beyond my current knowledge base, and I have been struggling to find a simple answer from searches, that I actually understand.
In short, I have a UserForm called Dashboard and three Labels which I use as buttons. They all do what I need them to do, but what I need help with is making the text inside the Label go Bold and Underlined when I move the mouse over the label.
I have managed to get it work, in a fashion, but its not perfect, as the code seems a bit longwinded and its having to overwork which is causing a delay.
This is what the form and buttons look like:
When I move the mouse over, it does what i want it to do, but as you can see if I move too quick I get multiple labels going bold and underlined,
This is the code I am using at the moment:
Private Sub Label4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Label4
.FontBold = True
.FontUnderline = True
End With
End Sub
And the code on the actual Dashboard userform as follows:
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Label4
.FontBold = False
.FontUnderline = False
End With
With Label1
.FontBold = False
.FontUnderline = False
End With
With Label5
.FontBold = False
.FontUnderline = False
End With
etc etc etc
As I have multiple labels, I dont think this code is exactly efficient because everytime I move it has to check each and every label, hense the delay (well that is what I am thinking anyway)
So what i am wondering, is it possible to simplify this code so it not having to look at each label individually. I was thinking maybe if I can use the Tag option in the Properties and put the ones I treat as buttons to "Buttons" in the tag and then have a piece of code that simply says, if the item is a label and it has a tag called button, the font goes bold and underlined when the mouse moves over it but then it's just normal text when the mouse is elsewhere.
Is that possible, and if so, how would I go about coding that, as I mentioned above, I am at the edge of my knowledge already and this is requires knowledge I dont currently know.
Any help would be appreciated.
Many thanks
Mark
Before I post the actual question, I think its worthwhile letting you all know that I am only just learning about VBA coding, so my knowledge is very basic. Most of what I have learnt is from recording macros and then converting it to VBA coding and then tidying it up. Plus coding that I have gathered from google searches.
Yet the one thing, I am trying to do is beyond my current knowledge base, and I have been struggling to find a simple answer from searches, that I actually understand.
In short, I have a UserForm called Dashboard and three Labels which I use as buttons. They all do what I need them to do, but what I need help with is making the text inside the Label go Bold and Underlined when I move the mouse over the label.
I have managed to get it work, in a fashion, but its not perfect, as the code seems a bit longwinded and its having to overwork which is causing a delay.
This is what the form and buttons look like:
When I move the mouse over, it does what i want it to do, but as you can see if I move too quick I get multiple labels going bold and underlined,
This is the code I am using at the moment:
Private Sub Label4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Label4
.FontBold = True
.FontUnderline = True
End With
End Sub
And the code on the actual Dashboard userform as follows:
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Label4
.FontBold = False
.FontUnderline = False
End With
With Label1
.FontBold = False
.FontUnderline = False
End With
With Label5
.FontBold = False
.FontUnderline = False
End With
etc etc etc
As I have multiple labels, I dont think this code is exactly efficient because everytime I move it has to check each and every label, hense the delay (well that is what I am thinking anyway)
So what i am wondering, is it possible to simplify this code so it not having to look at each label individually. I was thinking maybe if I can use the Tag option in the Properties and put the ones I treat as buttons to "Buttons" in the tag and then have a piece of code that simply says, if the item is a label and it has a tag called button, the font goes bold and underlined when the mouse moves over it but then it's just normal text when the mouse is elsewhere.
Is that possible, and if so, how would I go about coding that, as I mentioned above, I am at the edge of my knowledge already and this is requires knowledge I dont currently know.
Any help would be appreciated.
Many thanks
Mark