Positioning a Userform Over a Cell

keepITcool has developed a method to position a userform over a specific range. Finding a range’s screen coordinates is tricky. I usually resort to “close enough”.

He says:

First I found a bug. Excel 97 thru 2007.
The VisibleRange of Pane 2 and 3 (in a 4 pane window) are inconsistent.
depending on the sequence in which the vertical and horizontal split bars are set it will sometimes
return the range of the upper-right pane, sometimes the lower-left… and in both panes it may return activepane.index = 2
I found the cause and a workaround.

I soon got desperate using PointsToScreenPixels with non-standard zoom. Then I found that using XLM macro’s is the only reliable way to consistently get the “crosshair” on the screen under a variety of splits, zooms and display options. Some fiddling to offset from that point in case of frozen panes.. et voila!

You can download RangePos Beta1.zip.

Update: Download RangePos Beta3.zip

10 Comments

  1. Rob van Gelder:

    There might be a problem with the hyperlink Dick. Try this: download RangePos Beta1.zip

  2. ross:

    Does Chip not already shave some code to do this?

  3. Dick Kusleika:

    Thanks Rob. You’d think after all this time I would remember to put the http in front of email addresses. If I don’t, WordPress sticks this site’s URL in front. The original link is now fixed.

  4. Rob van Gelder:

    If the top-left pane is scrolled down a few rows, say to row 10, and you click in the bottom-left pane in cell B20, the form appears in the wrong place.
    I’m running Excel 2002 SP3 on Windows XP.

  5. Ross:

    Inresting,
    (win xp, xl 2000, 1060/768)
    Jurgen form did not postion correctly over the selected cell, and was not quite the right size, although the size did change with diffrent cell sizes.

    Chips[http://www.cpearson.com/Excel/FormPosition.htm] postioned correctly with out splits but not with.

    If i get some time I might have a play.

    Cheers
    Ross

  6. keepITcool:

    I sent Dick this Beta1 on July 16th…
    In the meantime I found some probs myself and tried to iron them out.. but never bothered to mail the current Beta3.

    Jurgen

  7. suseu:

    Vertical position does not work properly. Switching to 75% makes mouse behave strange way - it seems I have no control over it. Windows XP, Excel 2000.

  8. DM/Diddy:

    Thanks, keepITcool,

    This works well enough that I’ve incorporated it into a project.

    I’m impressed that it works on my multi-screen setup, since even Excel can’t always figure out where to pop up its dialogs. As for the few cases where the form doesn’t exactly show where I want it to, well, close enough…

    Thanks again.

    Dave

  9. Hollywood » Comment on Positioning a Userform Over a Cell by DM/Diddy:

    […] admin wrote an interesting post today onHere’s a quick excerptThanks, keepITcool,. This works well enough that I’ve incorporated it into a project. I’m impressed that it works on my multi-screen setup, since even Excel can’t always figure out where to pop up its dialogs. As for the few cases where … […]

  10. Hollywood » Comment on Positioning a Userform Over a Cell by Hollywood …:

    […] unknown wrote an interesting post today onHere’s a quick excerptadmin wrote an interesting post today onHere’sa quick excerptThanks, keepITcool,. This works well enough that I’ve incorporated it into a project. I’m impressed that it works on my multi-screen setup, since even Excel can’t always … […]

Leave a comment