Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Positioning a userform properly

Posted on 2011-09-02
4
Medium Priority
?
300 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 2000 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

876 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