Solved

Positioning a userform properly

Posted on 2011-09-02
4
276 Views
Last Modified: 2012-05-12
I understand that a userform's .left and .top properties are numbers that relate to the current screen.

I have a userform that I need to popup to the right of a button I have on my sheet. The button is positioned at Range("AY1").Left - 10.

Since Range().Left is a distance from column A to whatever range I'm specifying, I can't use that to position my userform. For me, Range("AY1").Left is 2548.5. My screen (Application.Width) is 972.

I'm not sure how I go about setting my startup position of my userform to where I want it to be (which is basically at ".Left of my button + .width of my button + 5" or something close to that).

I know I _could_ do Range("AY1").Left - Range("AL1").Left, but there's no guarantee that for someone else, the left-most column of the current window will be AL. I feel like I need to somehow find out where on my current window Range("AY1").Left is...

I hope I'm not completely overthinking this and am missing something obvious, though that's always possible. :)

Thanks in advance as always.
0
Comment
Question by:KenHadley
  • 2
4 Comments
 
LVL 12

Expert Comment

by:telyni19
ID: 36475506
So you want a userform to appear to the right of a button that could be off the screen if the sheet is scrolled to the left? Does this button trigger the form? In other words, does the button have to be in a visible place in order for the form to appear?

I think by definition, if you're using a pop-up form, it has to be on-screen, so it has to appear somewhere in the visible width of your file. The way you've described the file so far, that may or may not include your button.
0
 

Author Comment

by:KenHadley
ID: 36475636
> Does this button trigger the form? In other words, does the button have to be in a visible place in order for the form to appear?

Yes. The form won't be an issue if the button is off-screen.

I've attached a picture that shows exactly what I've been talking about. The calendar (userform) was popped up by clicking the calendar button. I've positioned it according to my screen & resolution manually, but ofc I want this automated to be able to adapt to various resolutions. But where it is now is basically where I'd like it to be on any computer this file is used with.

Hope this is a little more clear. Let me know if there's any other questions.

ee-buttonwithform.jpg
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 36483640
It's not obvious - see Chip's page here: http://www.cpearson.com/Excel/FormPosition.htm

If you are using a version of Excel pre 2007, you can also create a tiny blank chart, activate it and use the position of the chart window to locate the form, but from 2007 onward, that window doesn't exist. (you can use the formula editing window if you have in-cell editing switched on, but that's messy)
0
 

Author Comment

by:KenHadley
ID: 36503417
Thanks rorya. Guess it's not as easy as I was hoping it would be. I think Chip's page will get me to where I need to be, so thanks for the link!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question