Solved

Positioning a userform properly

Posted on 2011-09-02
4
269 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
Comment Utility
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
Comment Utility
> 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now