UserForm Controls Alignment

KG Old Wolf

Board Regular
Joined
Sep 20, 2009
Messages
65
All,

Is there an easy way to set a standard distance between controls (i.e. labels and text boxes)?

It's easy enough to "select all" and get edges, height etc. the same and aligned but there has to be a better way of establishing a standard amount of separation between a set of controls without have to zoom in on the form and count the little pixel dots!

I've got to be missing something fundamental!

Thanks,
KG
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Hermanito

Well-known Member
Joined
Apr 4, 2007
Messages
1,238
There is no way to distribute controls evenly over a certain distance...

But you can use the grid to snap to... that makes it fairly easy to get equal distances between controls...
Go to Options, General tab, and make sure the 'Align Controls to Grid' option is checked.
 

SamTYler

Well-known Member
Joined
Mar 10, 2004
Messages
784
Dim StandardSpace As Long
Ctrl2 left = Ctrl1.Left + Ctrl1.Width + StandardSpace
 

Hermanito

Well-known Member
Joined
Apr 4, 2007
Messages
1,238
I'll have to rephrase my words to
There is no way to distribute controls evenly over a certain distance... in the formdesigner at design-time.

Sam is right of course, at runtime you can move around everything, but that doesn't make designing the form any easier :)
 

KG Old Wolf

Board Regular
Joined
Sep 20, 2009
Messages
65

ADVERTISEMENT

Thanks Guys....

Sam, your solution is especially sweet
 

SamTYler

Well-known Member
Joined
Mar 10, 2004
Messages
784
Oh, yeah! I typically spend more effort in Designing the Form than I do on Run Time Code.

As in everything else we do, the more effort spent in preparation, the less spent on the "Real" work and the better the project turns out.

Here's a short lesson I wrote for a tutorial, (still under construction,) that shows just how much time is spent before I even open Excel.

http://forums.delphiforums.com/n/mb/message.asp?webtag=contractorxl&msg=40.1
 
Last edited:

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,225
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

In design view select all the controls and goto Horizontal/Vertical spacing.

You should now be able to space them evenly and increase/decrease the space between them.
 

Hermanito

Well-known Member
Joined
Apr 4, 2007
Messages
1,238
Oops :eek:

You are totally right Norie, as usual :)

I should have taken a look in the menus instead of only checking the buttons on the Userform toolbar...

In my defense, I swear that those options were not there before tonight!! :biggrin:
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,225
Office Version
  1. 365
Platform
  1. Windows
Hermanito

I don't know why but those options seem to have been hidden away.

I'm sure in the past I've added them to the right click menu or created a new menu on a toolbar for them.

Can't be bothered to do that sort of thing anymore.:)
 

stuart_mackay

New Member
Joined
Dec 29, 2018
Messages
1
Hi All,

After placing all text boxes on the form do the following:
1. group all boxes
2. use the Align to Grid tool (and align Left or Right) - this will align all boxes vertically (Alternatively you can use the Format tab and click Align)
3. on the Format (tab) use: Vertical Spacing > Make Equal (this will equally space the text boxes down the form)
 

Watch MrExcel Video

Forum statistics

Threads
1,123,194
Messages
5,600,262
Members
414,374
Latest member
akbir

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top