+ Reply to Thread
Results 1 to 6 of 6

Data Validation drop-down click event

  1. #1
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Data Validation drop-down click event

    Would it be possible to react to the click event on the drop-down handle in a cell with Data validation applied?

    I need to zoom in when the handle is clicked (and out again when the selection was made)...

    DataValidationDropDownClick.png

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: Data Validation drop-down click event

    There is no simple way to program an event to respond to a list expansion in a cell.
    In general, this problem is resolved using the Worksheet_SelectionChange event. When a cell contains a list, the sheet view magnifies, otherwise it reverts to the defined Zoom size.
    Insert the following code into the worksheet module:
    Please Login or Register  to view this content.
    Artik

  3. #3
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Re: Data Validation drop-down click event

    Dziękuję za odpowiedź, Artik.

    That is indeed the direction I also followed, by the absence of a drop-down click event.
    Nice work on how you dynamically determined the Validation ranges - I had made them a named range.

    What I didn't like is that after you select the cell with the Validation in it, you have to take a second action to open the drop-down.

    Then, after making the selection, you stay in the same cell, so the original zoom state is not returned.

    I fixed that with the following code (your code with some minor adjustments):
    I automatically expand the list and select the next cell (which could evetually be the next validation list) after the change.

    Please Login or Register  to view this content.
    DropDownValidationZoom.xlsm

    Grtz, BartH
    Last edited by BartH_NL; 01-28-2022 at 10:01 PM. Reason: Found error

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: Data Validation drop-down click event

    Quote Originally Posted by BartH_NL View Post
    Please Login or Register  to view this content.
    Wrrrrrr, my NumLock (not only mine, half the world problem) is going crazy.
    I've been using the Win API for a long time. Does not cause NumLock problems and is more reliable than SendKeys (but NOT 100% reliable!).
    Please Login or Register  to view this content.
    Artik
    Last edited by Artik; 01-28-2022 at 10:36 PM.

  5. #5
    Registered User
    Join Date
    07-20-2015
    Location
    Netherlands
    MS-Off Ver
    Win10, Off2019-365
    Posts
    44

    Re: Data Validation drop-down click event

    Ah, Artik,

    I remember having seen that too a couple of times (like on Citrix).
    Had found another solution for that, but would have to look that up.

    This Win API solution works well too.
    (I am curious to understand when or why the first or second solution - you mention it also isn't bullet-proof - does or doesn't work.)

    I've had to edit the API declaration as I use a 64b Windows/Office version:
    Please Login or Register  to view this content.
    I've updated the sample workbook: DropDownValidationZoom.xlsm

    Grtz, BartH
    Attached Files Attached Files
    Last edited by BartH_NL; 01-29-2022 at 02:41 AM. Reason: Found error

  6. #6
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,222

    Re: Data Validation drop-down click event

    In your case, I think keybd_event should work 100% because there is no window change in the code. The problem starts when we want to unload the keyboard buffer in another window. The buffer is unloaded to the first active window after issuing the command. We can never be sure (and we have no influence on it) that it will be "our" window. It may happen that between two commands (loading the buffer and activating our window) the system (Win) activates other window for a while, and the buffer will be unloaded to it. Maybe I am wrong, but somehow I have to explain this world to myself.

    Quote Originally Posted by BartH_NL View Post
    Had found another solution for that, but would have to look that up.
    I'd love to get to know another approach to SendKeys

    Artik
    Last edited by Artik; 01-29-2022 at 02:30 PM.

+ 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. Is there an event that gets executed before I Click on a cell with a validation popup?
    By lord anubis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2020, 06:54 AM
  2. [SOLVED] Data Validation (Dynamic) Drop Down WITH COMBO BOX on DOUBLE CLICK, INDIRECT not working
    By georgedixon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2017, 07:50 AM
  3. [SOLVED] ActiveX combobox click triggers unwanted another comboxbox click event
    By aprildu in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-12-2015, 10:08 AM
  4. Code to use for a click event to match data in a range
    By Pyro Form in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2012, 10:14 PM
  5. Prevent ListBox Click Event Until Mouse Click
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2011, 12:23 PM
  6. Change Event with Drop Down Validation List
    By gophins in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-03-2009, 11:20 AM
  7. userform label double-click goes to click event
    By John Paul Fullerton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2006, 01:00 PM

Tags for this Thread

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