2

Is there a way to add gridlines and snap objects to gridlines in an Excel VBA Userform?

I am generating a UserForm in Excel VBA with numerous textboxes and labels. Aligning them, even with the auto-align and grouping tools is quite tedious and time-consuming. The process would be expedited if horizontal and vertical gridlines were available to snap the objects to (think AutoCAD). The default UserForm has grid dots but not lines and snapping must be manually enabled for each object; it is not a built-in default for all objects.

4
  • Those features don't exist built-in, but maybe there is an add-in for it. I doubt it though.
    – Michael Z.
    Jul 3, 2017 at 23:55
  • Not that I know of. The snapping behavior is a bit 50/50, depending on the control it will align to the dots or not when resizing. The top left point is aligned with the dots when dragging the control around. You could of course just add the controls at runtime from within the code and do the alignment and sizing there. Jul 4, 2017 at 5:19
  • If you're generating the form in VBA, you can put the controls exactly where you want, so I don't really understand the question.
    – Rory
    Jul 4, 2017 at 7:04
  • Hi Rory, that's true but grid-lines are just easier on my eyes; I would also rather not hard code the control positions.
    – Paul NoCal
    Jul 5, 2017 at 7:02

1 Answer 1

1

Turn on "Align Controls to Grid" in Tools => Options (dialog box) / General (tab) as shown below.

enter image description here

1
  • Thanks--I already knew how to do this though. It appears that there's way to add grid lines and I just have to settle for grid dots :(
    – Paul NoCal
    Jul 5, 2017 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.