Scroll Bars in UserForms

J

Jmbostock

I've a userform that sometimes extends beyond the edge of the screen, so
i'd like to put a vertical scroll bar in to view the whole thing.

I've tried google, but the closest i got was a page in german, which i
don't speak.

Can anyone explain or direct me to a webpage that can tell me how to
put a scroll bar into a large userform to scroll to the bottom and top.


I'm not sure if it matters, but the userforms size is variable based on
the number of rows matching particular criteria. I can't imagine it
will, but just thought i would mention it just in case it effects it.

Thanks

James
 
H

Harald Staff

Hi James

Put a Frame1 on a new userform. Put a Frame2 inside Frame1. Put whatever
onto Frame2 just to watch. Insert a vertical Scrollbar1. Try this code:

Private Sub UserForm_Initialize()
Frame2.Height = Frame1.Height * 2
ScrollBar1.Max = Frame1.Height
ScrollBar1.LargeChange = ScrollBar1.Max / 4
ScrollBar1.SmallChange = 8
End Sub

Private Sub ScrollBar1_Change()
Frame2.Top = -ScrollBar1.Value
End Sub

Private Sub ScrollBar1_Scroll()
Frame2.Top = -ScrollBar1.Value
End Sub
 
T

Tom Ogilvy

Userform
ScrollBars

Look at the properties of your userform. See what the height of the form
is. Assume it is 300

Now look at the scroll height property and set it to match ( 300 for the
example)

Now go back to the height property and make it something small. Start with
half the height (150 for the example)


Set the scrollbars property to frmScrollBarsVertical

now show your form.

You should be able to scroll your form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top