+ Reply to Thread
Results 1 to 19 of 19

To highlight Frame with Label

  1. #1
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    To highlight Frame with Label

    Hi,

    I will have frame more than 10 which the frame in Multipage1.
    I would like to highlight the Frame with Label as "line/box highlighter", if the mouse move over the frame.
    I got the code from this forum and write it as on the file as reference, unfortunately the Label is not highlight as expected.
    Anybody would like to helps to solve the code, in advance highly appreciated.

    Best Regards,
    Iqballhud
    Attached Files Attached Files

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,479

    Re: To highlight Frame with Label

    Here is sample code to highlight label frame on mouse over :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    Re: To highlight Frame with Label

    HI Logit,

    Thank you for the replied.
    is there any way to highlight the frame?
    Because It will need more labels to highlight.
    If possible by use one label, it could be highlighted for all the frame which the mouse will move over them.

    Iqballhud

  4. #4
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    368

    Re: To highlight Frame with Label

    Quote Originally Posted by iqballud View Post
    Because It will need more labels to highlight.
    Maybe a higher driving school?

    We will use the class - Insert menu -> Class Module
    Attached Files Attached Files
    Last edited by hungt; 06-05-2025 at 03:25 AM.

  5. #5
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    Re: To highlight Frame with Label

    Hello HungT,

    Thank you so much for your code.
    It looks need to add Label on each frame, to make the frame will highlight with Label.
    And to use one Label (i.e.: lb1a) to highlight in all frame on Multipage, this is too hard, maybe.

    Kind regards,
    Iqballhud

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,479

    Re: To highlight Frame with Label

    Try this version :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    368

    Re: To highlight Frame with Label

    Quote Originally Posted by iqballud View Post
    .
    It looks need to add Label on each frame, to make the frame will highlight with Label.
    And to use one Label (i.e.: lb1a) to highlight in all frame on Multipage, this is too hard, maybe.
    1. And why did you add Labels if you don't want Labels? You added 6 Labels.

    2. Remove 6 Labels: Label1-Label6 on Page1 and Page2.

    The code supports 6 Frames: fr1-fr6 on Page1 and Page2

    3. If you have 20 Frames, do you also want to write 20 sub MouseMove?
    If you use lb1a, you need to know that you can move lb1a near Frame (change TOP, LEFT) but this Label lb1a is UNDER MultiPage, so you don't see lb1a anyway. If you want to use lb1a, wait for others. I've already given you the solution.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    Re: To highlight Frame with Label

    Hello HungT,

    I my project, I will use so many labels inside the frame and the frame that i will use, the numbers is huge too.
    I was thinking, with the code model as my #1 post (file attached), I can use the similar model/method to display the label (as highlight, "lb1a") outside the Frame.
    Because the sample, it is working if the Frame/Label order is in parallel, when I modified irregularly frame/label location the code is not working.
    This sample, it's use with one label as "lb1a".

    Kind regards,
    Iqballhud
    Attached Files Attached Files

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,479

    Re: To highlight Frame with Label

    Maybe this ?

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    368

    Re: To highlight Frame with Label

    At first I thought you wanted Label lb1a to completely COVER all the controls (e.g. CommandButton, Label, ComboBox, ListBox) lying on the Frame. If there is no such requirement, we can make the Label LARGER than the Frame, then we can SEE the 4 edges of the Label even though the Label lies UNDER the Frame.

    Note:
    1. Label1 must lie on the Page, i.e. Label1 and Frame fr1, fr2, fr3 MUST lie on the SAME Page, not on UserForm.
    2. I did it for Page1. Do it exactly the same for Page2
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    Re: To highlight Frame with Label

    Hellooo HungT,

    Thank you... thank you... thank you soo muchhh, Sir.
    Yes, like what I'm expected, one label to highlight for some frames.
    is it possible the label to highlight, it can be worked for another pages?
    Because, it looks only work in one page (in multipage) only.
    Again thank you very much and really really appreciated, Sir.

    Best Regards,
    Iqballhud

  12. #12
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    Re: To highlight Frame with Label

    Maybe this ?
    I need the frame/label will highlight with the line (from label), not by color.
    Anyhow, thank you so much for your coding, Logit.

    Best Regards,
    Iqballhud

  13. #13
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    368

    Re: To highlight Frame with Label

    Label (CommandButton, ComboBox ...) placed on Form is visible only on Form. If in a given position there is Label, Frame or MultiPage then Label is UNDER Frame, MultiPage, i.e. Frame, MultiPage COVERS Label. In case of Frame you can make Label bigger. Then Frame covers only the inside of Label, and 4 edges are visible.

    I added Label1 on Page1 because if I put Label1 on UserForm, even though Label1 is moved (changes LEFT, TOP) it is still impossible to see Label1. You have to put Label1 on Page1, then you can see on Page1, and since it is covered by Frame you can play around by making Label bigger. Label1 is of course visible only on Page1. That is why I wrote to put Label2 on Page2, and of course you also have to add code for fr4, fr5, fr6.

    I gave the simplest way, and the least code in post #7, but you did not want to.

    If you don't want to bother, we won't put Label anywhere during design time. The code creates Label Runtime
    Attached Files Attached Files
    Last edited by hungt; 06-06-2025 at 11:04 AM.

  14. #14
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    Re: To highlight Frame with Label

    Mr. HungT,

    I don't know how to express my gratitude to you, Sir.
    Your code is really really really worked and as I expected.
    Yes, this is what I'm looking for, highly appreciated, and again big thanks to you, Sir.
    I wish all the best wishes and happiness to you, sir.

    Mr.HungT, what i understand, the "Label1", this is just created as script/code (I don't know what should i call).
    Because I'm searching, I could not find physically the "Label1" inside the pages (Multipage)

    Best Regards,
    Iqballhud

  15. #15
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    368

    Re: To highlight Frame with Label

    Label1 is created and placed on Page1, Page2, but exists only in run time. In design time it does not exist.

  16. #16
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    Re: To highlight Frame with Label

    Mr. HungT,

    Thank you.. thank you so much for the explanation.
    Label1 is created and placed on Page1, Page2, but exists only in run time. In design time it does not exist.
    Based on that quote, then I was worried, then I tested with the timer, the code is working.
    And when I changed (in four places) the name of "Label1" with others name, i.e. "Label2", or "Label1a", the code is hang, do not work.

    And also, when I put inside the frame like, "CommandButton", "Label", "ListBox", then it use as Control to highlight the "Frame", the results is the "Label1" as highlight is on the top corner only.
    As i understand, because of the outside line as control is "Frame" and this is only work if the "Frame" as control as "Frame.MouseMove".

    Is it possible, to use inside the frame as control to highlight the frame, please?
    and also, is it possible to change the name instead of "Label1", it could be changed as others?

    Again, thank you, thank you and very big thank you from me, Sir.

    Best Regards,
    Iqballhud
    Attached Files Attached Files

  17. #17
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    368

    Re: To highlight Frame with Label

    You have almost no knowledge so I have to explain everything to you, and it takes a lot of time.

    You have to understand that each control (child) lies either on a UserForm, or on a Page (MultiPage), Frame … (parent). When you specify LEFT, TOP of a control you give it COORDINATES in the coordinate system of ITS PARENT. I will give examples.

    On UserForm frm1 you have a MultiPage1 control. You click and you will see in the Properties window its left = 18, top = 24 (I move MultiPage1 to explain). These coordinates are in the UserForm system because MultiPage1 is its child. The xOy system has its origin O in the upper left corner of the UserForm client area, the Oy axis is directed down, the Ox axis is directed to the right. Frame fr1 has left = 120, top = 66. These coordinates are in the MultiPage1 system because Frame fr1 is its child. CommandButton1 has left = 0, top = 0. These coordinates are in Frame fr1 because CommandButton1 is its child. See the image.

    uklad.png

    Now let's analyze the code.

    1. According to my code for fr1.Left = 120, fr1.Top = 66, fr1.width = 132, fr1.height = 78
    Please Login or Register  to view this content.
    Label1.left = c.left - 2 = fr1.left - 2 = 120 - 2 = 118
    Label1.top = c.top = fr1.top - 2 = 66 - 2 = 64
    Label1.width = c.width + 4 = 132 + 4 = 136
    Label1.height = c.height + 4 = 78 + 4 = 82

    Label1 and fr1 are children of the same parent Page1, so their similar coordinates are calculated in the same coordinate system. Therefore Label1 lies "around" fr1.

    2. According to your code for CommandButton1.left = 0, CommandButton.top = 0, CommandButton.width = 132, CommandButton1.height = 72

    Please Login or Register  to view this content.
    Label1.left = c.left - 2 = CommandButton1.left - 2 = 0 - 2 = -2
    Label1.top = c.top = CommandButton1.top - 2 = 0 - 2 = -2
    Label1.width = c.width + 4 = CommandButton1.width + 4 = 132 + 4 = 136
    Label1.height = c.height + 4 = CommandButton1.height + 4 = 72 + 4 = 76

    Since the code creates Label1 as a child of Page1, the coordinates of CommandButton1.left = -2 and CommandButton1.top = -2 are calculated in the coordinate system of Page1 and not in the coordinate system of Frame fr1. fr1 and Label1 are children of the same parent Page1, so their coordinates are calculated in the same system. fr1.Left = 120, fr1.Top = 66 so fr1 is far from the beginning of the MultiPage Coordinate System, Label1.left = -2, Label1.top = -2, so Label1 is near the beginning of the MultiPage Coordinate System.

    Now you will understand why Label1 is on the top corner only?
    -------------
    Corrected code in the UserForm module frm1

    Please Login or Register  to view this content.
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    251

    Re: To highlight Frame with Label

    Mr. HungT,

    I was laughing toooo much, Sir... because you can identify me very well, which i have knowledge (almost) about VBA especially.
    Honestly, I learnt the VBA from the google mostly, without teacher to teach me, which one is right which one is wrong.

    When you can solve the problem with very very super easy, with deep understanding about the situation.... hats off from me to you, Sir.
    And you can clearly explained and teach me about the how the parents and child will work.
    Before I was just read about it, but don't know how to use it and what is the correct meaning, but after you explained, it's clear to me now.
    Mr.HungT, again and again... from deep my heart, big thanks to you, Sir.
    All the best wishes and happiness to you and your family, Sir.

    I will mark this post as SOLVED and I will saved your explanation in my personal notes.

    Best Regards,
    Iqballhud

  19. #19
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    368

    Re: To highlight Frame with Label

    Quote Originally Posted by iqballud View Post
    All the best wishes and happiness to you and your family, Sir.
    From me to you and your family too, Sir

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Label Highlight and More than 10 Labels
    By iqballud in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-10-2025, 05:19 AM
  2. [SOLVED] Userform (contents label, frame, etc.) to fit with any Window Screen & Resolution
    By iqballud in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2022, 07:38 AM
  3. [SOLVED] Conditional Formatting: Highlight specific time frame
    By dlealb in forum Excel General
    Replies: 1
    Last Post: 02-23-2020, 01:30 AM
  4. Label On Frame
    By AlexanderBB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2019, 05:23 PM
  5. creating a userform, a frame and a label using VBA codes alone.
    By josaah in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-22-2016, 10:53 PM
  6. [SOLVED] Looping through controls by frame on userform (frame within a frame)
    By njs27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-27-2015, 10:21 AM
  7. Highlight checkbox and label
    By oxicottin in forum Excel General
    Replies: 1
    Last Post: 01-23-2015, 06:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1