Excel UserForm Scrollbar: Setup, Events, and Examples

VBA & macros · Updated November 18, 2026

To use a scrollbar on an Excel UserForm, add a ScrollBar control in the Visual Basic Editor, set its Min, Max, SmallChange, and LargeChange properties, then read its Value in a VBA event such as ScrollBar1_Change. The control is useful for choosing a value from a bounded range, such as a year or percentage, and displaying or applying that selection elsewhere in the form.

What a UserForm scrollbar does

A UserForm ScrollBar is a VBA form control with a movable thumb and arrow or track areas. The thumb position represents a numeric Value between the control’s Min and Max limits. A user can drag the thumb, click the arrows, or click the track to move through the available range. Your VBA code decides what that number means: it might represent a year, a record number, a zoom level, or a quantity.

The control does not automatically write its value into a worksheet cell or update another control. You supply that behavior in code. For example, a Change event can copy the scrollbar value to a label, while an Apply button can use the chosen value to filter data or update a cell. This separation is useful because it lets you decide whether changes should take effect immediately or only after the user confirms them.

A UserForm scrollbar is also different from a worksheet scrollbar. A worksheet control sits on a sheet and can be configured to link to a cell; a UserForm scrollbar belongs to a VBA form and is normally handled through its properties and event procedures. The instructions below are for Excel for Microsoft 365 on Windows.

Add a ScrollBar control to a UserForm

  1. Open the workbook in desktop Excel and press Alt+F11 to open the Visual Basic Editor. On a Mac, the shortcut can differ by keyboard and Excel settings; open the Visual Basic Editor from the Developer tab or Excel’s Tools menu if the shortcut does not work.
  2. In the editor, choose Insert > UserForm. If the Toolbox is not visible, choose View > Toolbox.
  3. Click the ScrollBar control in the Toolbox, then drag on the form to draw it. Add a Label control as well if you want to display the current selection.
  4. Click the scrollbar and use the Properties window to set its (Name), such as ScrollBar1. Set the label’s (Name) to lblYear, or choose names that describe your own controls.
  5. Double-click the scrollbar to open its code window and create its event procedure. You can also select the control and event from the code window’s object and procedure lists.

If the Toolbox or Properties window is missing, use the View menu in the Visual Basic Editor. These are VBA design-time tools; they are not the same as the Developer > Insert controls used to place controls directly on a worksheet.

Set the scrollbar properties

The key properties are available in the Properties window or can be set in VBA when the form opens. Min and Max define the allowed endpoints. Value is the current selection. SmallChange is the amount moved by a small arrow action, while LargeChange is the amount moved by a larger track action. Choose values that make navigation comfortable for the range and task.

  • Min and Max: Set these to the smallest and largest meaningful choices. For a year selector covering 2000 through 2030, use 2000 and 2030.
  • Value: This is the current position. Set it to an initial valid choice, such as the current year if that year is inside the range.
  • SmallChange: Use 1 when each arrow action should move to the next year or item. A larger number skips more values.
  • LargeChange: Set the larger step used when clicking the track. For a 31-year range, a step of 5 may be more convenient than a step of 1.
  • Orientation: Choose a horizontal or vertical layout that fits the form. The control’s direction should be visually clear to users.

Keep the range modest and meaningful. A scrollbar is not a good way to enter an extremely precise number: users may have difficulty positioning the thumb accurately, and the control’s numeric limits are not intended to replace a suitable text-entry design for every data range. For decimal choices, use an integer scale and convert the selected integer in code.

Example: select and display a year

This example assumes a UserForm contains a ScrollBar named ScrollBar1 and a Label named lblYear. It sets a range from 2000 to 2030, starts at 2024, and refreshes the label whenever the value changes. Put the code in the UserForm’s code module, not in a standard module or a worksheet module.

Private Sub UserForm_Initialize()
    ' Set a bounded year range and a useful starting value.
    With Me.ScrollBar1
        .Max = 2030
        .Min = 2000
        .SmallChange = 1
        .LargeChange = 5
        .Value = 2024
    End With

    UpdateYear
End Sub

Private Sub ScrollBar1_Change()
    UpdateYear
End Sub

Private Sub UpdateYear()
    Me.lblYear.Caption = CStr(Me.ScrollBar1.Value)
End Sub

UserForm_Initialize runs when the form is initialized, so it is a suitable place to establish the range and starting value. ScrollBar1_Change runs when the value changes, and UpdateYear keeps the display logic in one place. If you rename either control, update every matching reference in the code. To try the form, run it from the Visual Basic Editor or call its Show method from a macro.

Before running VBA, save a copy of the workbook. Macros cannot be undone with Ctrl+Z. Save a macro-enabled workbook as .xlsm if it needs to retain VBA code, and use only macros you understand and trust.

Use the value for other purposes

The label is only one possible destination. You can use the selected number to choose an item in a list, determine how many records to show, or set a value after the user clicks an Apply button. For example, a year scrollbar can update a report after the user confirms the year. Keeping that work in a separate button event avoids recalculating a report on every small movement while the user is still choosing.

If you want immediate updates, place the relevant action in the Change event or call a separate procedure from it. Keep event code short and move reusable work into named procedures. If each scrollbar movement triggers a slow worksheet operation, the form may feel unresponsive; updating a label immediately and applying the selection only on confirmation is often a better interaction.

For a decimal selection, map an integer value to a decimal amount. For example, a scrollbar with Min set to 0 and Max set to 100 can represent 0.00 through 1.00 by dividing its Value by 100 in VBA. Display the result with an appropriate format, and ensure the label explains the scale so that users do not mistake 75 for 75.00 when it actually means 0.75.

Scrollbar, SpinButton, or text box?

Choose a scrollbar when users benefit from seeing the approximate position within a range or moving quickly through many nearby choices. A SpinButton is usually better for repeated, controlled increments, especially beside a text box that shows the exact value. A text box is more suitable when users know the precise number they want to enter, or when the range is too wide for accurate thumb positioning.

These controls can also work together. A text box can show or accept an exact value while a scrollbar offers a convenient way to browse. If users can type into the text box, validate the input before using it and keep it within the scrollbar’s Min and Max range. Do not assume that a scrollbar alone makes a numeric value self-explanatory; label the units and meaning, such as Year, Items, or Percent.

Common problems and fixes

  • The code does not run when the value changes: Confirm that the procedure is in the UserForm module and that its name matches the control, for example ScrollBar1_Change. A similarly named procedure in a worksheet module will not handle the form control’s event.
  • The displayed number is wrong or does not change: Check the control names in the Properties window and make sure the code refers to the same names. Also verify that the label is on that UserForm and that the Change event calls the display procedure.
  • The initial value is outside the range: Set Min and Max before setting Value, then choose a Value between those endpoints. When changing a range at runtime, account for a current value that may no longer fit.
  • The scrollbar moves in awkward jumps: Review SmallChange and LargeChange. A large step can make fine selection difficult; a step of 1 is often appropriate for consecutive whole-number choices.
  • The form does not run in Excel for the web: Excel for the web does not run VBA UserForms. Open the macro-enabled workbook in desktop Excel to use this VBA interface.
  • The workbook behaves differently on a Mac: VBA and control availability can differ between platforms and versions. Test the form in the exact Mac or Windows environment where it will be used; worksheet ActiveX controls are Windows-specific.

Design and usability considerations

Give the scrollbar enough length and a clear label. A very short control can be difficult to operate, particularly when the range has many values. Display the current value beside it, and make the units explicit. If the selected value affects important data, provide a clear Apply, Update, or Cancel action rather than silently changing results while the user is still exploring.

Do not rely on color or thumb position alone to communicate the selection. A visible numeric value helps users who have difficulty judging position and makes the form easier to use with different display sizes. Consider whether a keyboard-friendly text box or SpinButton would be more appropriate for users who need precise entry. A scrollbar is an input aid, not a substitute for validating the value before using it in a calculation or worksheet operation.

Frequently Asked Questions

How do I get the value of a scrollbar on a UserForm?
Read the control’s Value property in VBA, such as Me.ScrollBar1.Value, from the UserForm module. Use the ScrollBar1_Change event if you need to respond whenever the user changes the selection.

How do I set the minimum and maximum values?
Set the control’s Min and Max properties in the Properties window or in UserForm_Initialize. Set those endpoints before assigning the initial Value, and choose a starting value that lies between them.

Why is my UserForm scrollbar not updating a worksheet cell?
A UserForm ScrollBar does not automatically link to a worksheet cell. Add VBA that writes its Value to the desired cell, or use a worksheet control if a linked-cell design is what you need.

Can I use a UserForm scrollbar in Excel for the web?
No. Excel for the web does not run VBA macros or display VBA UserForms as an interactive form. Use desktop Excel for this approach, or choose a non-VBA interface if browser access is required.

Should I use a scrollbar or a SpinButton?
Use a scrollbar when browsing a range and seeing approximate position is helpful. Choose a SpinButton for step-by-step changes, or a text box when users need to enter an exact value directly.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.