To add a scrollbar to an Excel UserForm, set the form’s ScrollBars property to vertical, horizontal, or both, then make ScrollHeight or ScrollWidth larger than the visible form area. In Excel for Microsoft 365 on Windows, you can set these properties in the VBA editor or in the form’s initialization code.
What a UserForm scrollbar does
A UserForm is a custom dialog box built with VBA. Its scrollbar lets a person move around a form whose controls do not all fit in the visible area. The form scrolls as a whole: labels, text boxes, buttons, and other controls placed on it move together. This is useful for long data-entry forms, settings dialogs, or forms that need to work on screens with limited height.
The UserForm’s scrollbar is different from a standalone ScrollBar control. A standalone control is an object you place on the form and connect to a value or procedure; it does not automatically move the form’s contents. For ordinary scrolling through an oversized form, use the UserForm’s built-in scrolling properties rather than adding a separate ScrollBar control.
Scrolling is also different from resizing. A scrollbar provides access to content outside the visible area without changing the form’s on-screen size. If all the controls already fit comfortably, adding scrolling may make the form less convenient rather than more useful.
How the scrolling properties work
The main settings are ScrollBars, ScrollHeight, and ScrollWidth. ScrollBars determines which directions are available: none, horizontal, vertical, or both. The height and width define the scrollable content area. For example, a vertical scrollbar is useful when the content extends farther down than the visible form; set the scroll height greater than the visible client area.
The properties use form coordinates measured in points. A control’s Top position and Height help determine how far down the content reaches; its Left position and Width matter for horizontal scrolling. Allow a little room beyond the last control so the bottom or right edge is not awkwardly clipped. The scrollbar moves through the scroll area; it does not enlarge or rearrange the controls.
KeepScrollBarsVisible controls whether the selected scrollbars remain visible even when the content does not require scrolling. If you want the interface to show a scrollbar only when there is content to reach, leave this setting at its default behavior rather than forcing the bar to stay visible. A visible scrollbar is not, by itself, proof that the scroll range has been configured correctly.
Set a scrollbar in the VBA editor
- Save the workbook as an Excel Macro-Enabled Workbook (
.xlsm) if it contains VBA that you need to retain. - Open the Visual Basic Editor with Alt+F11, or choose Developer > Visual Basic on the ribbon. If the Developer tab is hidden, enable it in Excel Options > Customize Ribbon.
- In the Project Explorer, open the UserForm. If you need to create one, use Insert > UserForm in the Visual Basic Editor.
- Select the form itself, not one of its controls. Press F4 to show the Properties window if it is not already open.
- Set
ScrollBarsto2 - fmScrollBarsVerticalfor vertical scrolling, or choose the relevant horizontal or both-directions option. - Set
ScrollHeightto a value greater than the form’s visible content area. For example, if the controls extend to about 430 points from the top, a scroll height around 460 points can provide a little bottom margin. - Run the form and try the scrollbar. Adjust the scroll height if the last control is still out of reach or if the scrollable blank area is excessive.
The exact visible area depends on the form’s dimensions and window chrome, so there is no universal scroll-height value. The practical check is to run the form and confirm that its first and last controls can be reached without leaving an unnecessarily large empty region.
Set the scroll area with VBA
For a form whose scroll area should be set consistently each time it opens, put the following procedure in that UserForm’s code module. It selects vertical scrolling and sets a 520-point scroll height:
Private Sub UserForm_Initialize()
' Enable vertical scrolling when the form opens.
Me.ScrollBars = fmScrollBarsVertical
Me.ScrollHeight = 520
End Sub
The 520-point value is an example, not a required setting. Change it to suit the controls on your form. If you want scrolling configured once in the designer, set the properties there instead; code is useful when the scroll area varies or you want the settings to be explicit. The form’s initialization event runs when the form is loaded, before it is shown.
Before running or distributing a macro-enabled workbook, save a separate copy. VBA macros cannot be undone with Ctrl+Z, so a backup is important when changing a working workbook. Also make sure the workbook’s macro security settings allow the code to run.
Choose vertical, horizontal, or both
Use vertical scrolling for forms with a list of fields arranged in columns. This is the common choice for an intake form or a long set of options. Keep the form reasonably narrow and make sure labels and input boxes remain aligned as the user moves down the page.
Use horizontal scrolling only when the content genuinely extends beyond the form’s width, such as a specialized layout with several wide columns. Horizontal movement can make labels and values harder to compare because the user may lose sight of context. If possible, reduce control widths, split the information into tabs, or use a more compact design before relying on horizontal scrolling.
Choose both directions only when the content exceeds the visible area in both dimensions. Two scrollbars can be harder to operate, especially on a small display, and can make it less obvious where a particular control is located. Consider whether a MultiPage control, separate forms, or a list with a detail area would make the task clearer.
Scrolling a frame or another container
A form can contain a Frame that groups related controls. If the oversized content is inside a frame, the frame may be the better scrolling surface: select the frame and inspect its own scrolling properties in the Properties window. Set the frame’s scrollbar direction and scroll extent to suit the controls inside it. This lets the form’s heading or action buttons stay fixed while only the grouped content moves.
Container boundaries matter. Controls placed directly on the UserForm are not the same as controls placed inside a Frame or on a MultiPage page. Set scrolling on the object that owns the content you want to move, and test the result at runtime. If controls overlap, disappear, or scroll independently of the intended group, check which container they belong to in the designer before increasing the form’s scroll dimensions.
A useful layout is a fixed title and action area with a scrolling body. For example, a form can keep its Save and Cancel buttons visible while a frame containing many optional fields scrolls. This reduces the chance that someone must scroll all the way to the bottom just to submit or close the form.
UserForm scrollbar versus a ScrollBar control
Use the built-in UserForm scrollbar when the goal is to reveal controls outside the visible portion of the form. Use a standalone ScrollBar control when the user should change a numeric value or drive another interface element. A standalone scrollbar has a value and settings such as its minimum, maximum, and increment; your VBA can respond to its change event. It does not automatically scroll a group of controls merely because it is on the form.
For example, a standalone scrollbar could be linked in code to a zoom-like setting or to a selected item number in a custom display. That requires you to write the behavior that updates the display. For a long questionnaire, the built-in scrolling properties are simpler and less error-prone because the form handles the movement of its content.
Common problems and how to fix them
- The scrollbar is missing: Check that
ScrollBarsis not set to none and that the corresponding scroll dimension exceeds the visible area. Confirm you selected the UserForm rather than a child control when changing the property. - The bar appears, but nothing useful moves: Increase
ScrollHeightorScrollWidthso the scrollable extent reaches beyond the visible region. Then test by moving the bar from one end to the other. - The last control is cut off: Increase the relevant scroll dimension enough to include the control’s full position and size, with a small margin. Also confirm the control is inside the form or scrolling container you configured.
- There is too much blank space: Reduce the scroll dimension. A much larger extent than the controls require creates a long empty stretch at the end of the scroll.
- The wrong object scrolls: Check whether controls are on the form, inside a frame, or on a MultiPage page. Configure the object that contains the content, and consider separating fixed buttons from the scrolling group.
- Changes in the designer do not seem to apply: Close and reopen the form after saving the project, and check whether
UserForm_Initializeor other code resets the properties when the form opens.
Test the form at the size and display settings people are likely to use. A design that fits on one monitor may need scrolling on another, and a long form should still be navigable with the keyboard. Use meaningful tab order, descriptive labels, and buttons that remain easy to find.
Mac and workbook compatibility
The steps and VBA example here target Excel for Microsoft 365 on Windows. Excel for Mac has VBA support, but the Visual Basic Editor and the availability or behavior of UserForm controls can differ from Windows. A Windows shortcut such as Alt+F11 may also require a different key combination or the Fn key on a Mac keyboard; use the Mac Excel menus or keyboard settings to open the editor.
If a workbook will be used on both platforms, test the actual form and its controls in each target Excel version. Do not assume that a form working on Windows will behave identically on Mac. Excel for the web does not run VBA macros, so a VBA UserForm is not an option for users opening the workbook there; a worksheet-based interface or another supported solution may be needed.
Frequently Asked Questions
How do I make a UserForm scroll vertically?
Set the UserForm’s ScrollBars property to fmScrollBarsVertical and give ScrollHeight a value larger than the visible content area. You can set both properties in the designer or in UserForm_Initialize.
Why is my Excel UserForm scrollbar not showing?
Usually the form is set to no scrollbars, the wrong object is selected, or the scroll dimension is not larger than the visible area. Check ScrollBars and ScrollHeight or ScrollWidth, then run the form to verify the result.
Can I keep buttons visible while the form scrolls?
Yes. Put the scrolling controls in a frame and keep the action buttons outside that frame, on the fixed part of the UserForm. Configure scrolling on the frame so only its contents move.
Does a ScrollBar control scroll the whole UserForm?
No. A standalone ScrollBar control provides a value that your VBA can use, but it does not automatically move the form’s contents. Use the UserForm’s built-in ScrollBars and scroll-dimension properties for that behavior.
Can an Excel UserForm run in Excel for the web?
No. Excel for the web does not run VBA macros, so VBA UserForms do not provide an interactive form there. Use a worksheet interface or another tool that works in the intended environment.
Related
- Excel Data Validation Source: Lists, Ranges, and Rules
- Excel Data Validation Rules: How They Work and When to Use Them
- Excel Data Validation Restrictions and Their Limits
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA: Get the Date to the Right of a StringIf a cell contains a text label and the date is in the cell immediately to its right,…
- Excel VBA Date Picker: Controls, Options, and FixesExcel for Microsoft 365 on Windows does not include a universal VBA date-picker control that you can simply…
- Excel VBA Copy Paste Transpose: Working Code and TipsTo copy a range and paste it transposed with Excel VBA, copy the source range and use PasteSpecial…
- Excel VBA: Get Last Row with Data (3 Ways)The quickest way to get the last row with data in Excel VBA is Cells(Rows.Count, 1).End(xlUp).Row, which returns…
- Filter an Excel PivotTable With VBA: Fields, Items, and CodeTo filter an Excel PivotTable with VBA, reference the PivotTable and field, clear any existing filter, then set…
- VBA Sort Table: Excel Code, Options, and Common IssuesTo sort an Excel table with VBA, get the table as a ListObject, add one or more sort…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.