ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scroll Bars in UserForms (https://www.excelbanter.com/excel-programming/286859-scroll-bars-userforms.html)

Jmbostock[_8_]

Scroll Bars in UserForms
 
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


---
Message posted from http://www.ExcelForum.com/


Harald Staff

Scroll Bars in UserForms
 
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



--
HTH. Best wishes Harald
Followup to newsgroup only please

"Jmbostock " skrev i melding
...
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


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

Scroll Bars in UserForms
 
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.

--
Regards,
Tom Ogilvy

"Jmbostock " wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com