Results 1 to 7 of 7

Thread: Floating Userform on Excel Spreadsheet

  1. #1

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Floating Userform on Excel Spreadsheet

    Hi All,

    Forgive me if I don't always use the correct terminology. I have what I call a 'floating' Userform (I think the term is modeless) on an Excel Spreadsheet with option buttons whose values change depending on the location and contents of cells that are clicked. The form is continuously visible as different cells are clicked and is normally de-highlighted until you actually click on the form. I use the Worksheet_SelectionChange event to trigger loading the values of the option buttons. Thus, as various cells are clicked, either with the cursor, or Enter key, or arrow keys, the option button values continuously change as the cells are traversed. This is as designed.

    Here's the problem. Apparently at random, when a cell is clicked, the form suddenly becomes highlighted, preventing further traversing of cells unless the cursor is used to click a cell (thus de-highlighting the form). The odd thing is that this strange behavior of the form suddenly becoming highlighted occurs at random. I've found a workaround by by setting the form Enable property to False, load the form values, then set the Enable property to True. But, I can't figure out why this is necessary.

    Any idea why the form suddenly becomes highlighted as I move among the worksheet cells w/ Enter or arrow keys?

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Floating Userform on Excel Spreadsheet

    Do you use the setfocus in your code on the event on cells?
    Perhaps one is firing when it shouldn't?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Floating Userform on Excel Spreadsheet

    Quote Originally Posted by Ecniv
    Do you use the setfocus in your code on the event on cells?
    Perhaps one is firing when it shouldn't?
    I'm not using setfocus. Should I be? I understand .visible and believe I understand .enabled, but I don't know how setfocus comes into play.

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Floating Userform on Excel Spreadsheet

    Uhh not sure it actually applies to Excel (sorry!).

    On Access forms, .SetFocus pulls the focus to the form/control. Thought there may be one in Excel.

    Can you re-call the .Show method? Would that refloat it back up?


    EDIT:
    A thought on the original post - how do you fill the values?
    Maybe the code is setting the focus/highlighting the field thus making the form active?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Floating Userform on Excel Spreadsheet

    What version of Excel are you running?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Floating Userform on Excel Spreadsheet

    Quote Originally Posted by RobDog888
    What version of Excel are you running?

    I'm using Excel 2002. The workaround seems to work, so I'm happy. However, I'm still curious as to the strange behavior.

    On another topic, thanks again for your help with the API - it works great.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Floating Userform on Excel Spreadsheet

    Glad to have helped and now I remember and see how this thread ties into your other thread.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width