Assigning MouseOver Events Programmatically

aommaster

New Member
Joined
Mar 13, 2004
Messages
23
Hello

What I have is a list of data on a sheet. Through some code, I would like to visualize my data in a certain way. What I currently have is a grid, each square corresponding to a single data point. I would like to assign a tooltip to a label that will be sitting on top each of these squares.

What I have so far:
I have a userform which will be populated by labels programmatically. I am doing it like this because there are at least a few thousand labels to be created. I am currently doing it like this:
Code:
counter = 15
    For i = 1 To 20
        For j = 1 To numrows
            Set thelabel = OwnChart.Controls.Add("Forms.Label.1", "x", True)
            With thelabel
                .Caption = "x"
                .Top = 29 + 10.3 * (j - 1)
                .Left = 20 + 10 * (i - 1)
                .width = 10
                .height = 10
                .BackStyle = 0
                .ForeColor = RGB(255, 255, 0)
                .ControlTipText = ActiveSheet.Range("A" & counter).Value
            End With
            counter = counter + 1
        Next
    Next

Essentially, what I have is a grid, and I would like to change the letter "x" in the label to another color when the mouse is hovering over the label.

Is this the correct way of achieving what I want, or is there a better way? Is there a way of assigning a single mouseover/hover event to the label once it has been created? (All these labels can be handled by a single function to just change the text color). How do I do that?

Thanks!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,196,513
Messages
6,015,642
Members
441,913
Latest member
Lhayden_69

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