ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scroll bar (https://www.excelbanter.com/excel-programming/366837-scroll-bar.html)

Viktor Ygdorff

Scroll bar
 
Hello! I have a user from that unfortunately has become very long. Therefore
I need a scrollbar so that the user shall be able to scroll his/her way down
to the end of the user form. I found something that looked like a scrollbar
in the tools for the user form but I do not know how to write code for it and
my help function for vba does not work. Please if you know how to write code
for this, help me out! Thank you!

Tom Ogilvy

Scroll bar
 
Why not use the built in scrollbar on the userform itself. Look at the
properties of the userform to turn on the scrollbar.

--
Regards,
Tom Ogilvy


"Viktor Ygdorff" wrote:

Hello! I have a user from that unfortunately has become very long. Therefore
I need a scrollbar so that the user shall be able to scroll his/her way down
to the end of the user form. I found something that looked like a scrollbar
in the tools for the user form but I do not know how to write code for it and
my help function for vba does not work. Please if you know how to write code
for this, help me out! Thank you!


Tom Ogilvy

Scroll bar
 
Or you could put this in your initialize event for the Userform:

Private Sub UserForm_Initialize()
UserForm1.ScrollBars = fmScrollBarsVertical
UserForm1.ScrollHeight = UserForm1.Height
UserForm1.Height = UserForm1.Height / 2
End Sub

This assumes in the VBE you can see the entire userform.

--
Regards,
Tom Ogilvy


"Viktor Ygdorff" wrote:

Hello! I have a user from that unfortunately has become very long. Therefore
I need a scrollbar so that the user shall be able to scroll his/her way down
to the end of the user form. I found something that looked like a scrollbar
in the tools for the user form but I do not know how to write code for it and
my help function for vba does not work. Please if you know how to write code
for this, help me out! Thank you!


Viktor Ygdorff

Scroll bar
 
Yes thank you! I did not know that there was a scroll bar
property..Unfortunately me hlep function in vba does not work and I am not
very good at this but I managed to show a scroll bar. However I do not think
it works. I do not see the small box on the scroll bar that you should be
able to pull up/down instead of using the arrows at the top/bottom. My code
is:

Private Sub UserForm_Initialize()
Me.ScrollBars = fmScrollBarsVertical
........

I would be very thankful if you could help me with problem! Thanks again
Tom! You save my life on a daily basis!
"Tom Ogilvy" skrev:

Or you could put this in your initialize event for the Userform:

Private Sub UserForm_Initialize()
UserForm1.ScrollBars = fmScrollBarsVertical
UserForm1.ScrollHeight = UserForm1.Height
UserForm1.Height = UserForm1.Height / 2
End Sub

This assumes in the VBE you can see the entire userform.

--
Regards,
Tom Ogilvy


"Viktor Ygdorff" wrote:

Hello! I have a user from that unfortunately has become very long. Therefore
I need a scrollbar so that the user shall be able to scroll his/her way down
to the end of the user form. I found something that looked like a scrollbar
in the tools for the user form but I do not know how to write code for it and
my help function for vba does not work. Please if you know how to write code
for this, help me out! Thank you!


Tom Ogilvy

Scroll bar
 
Use the code I provided. the scroll bar doesn't work until you make the
scrollheight equal to the actual height and then make the actual height to
something less. I made it 1/2 of the original height (so half the height is
always in view), but you can make it something else.

--
Regards,
Tom Ogilvy


"Viktor Ygdorff" wrote:

Yes thank you! I did not know that there was a scroll bar
property..Unfortunately me hlep function in vba does not work and I am not
very good at this but I managed to show a scroll bar. However I do not think
it works. I do not see the small box on the scroll bar that you should be
able to pull up/down instead of using the arrows at the top/bottom. My code
is:

Private Sub UserForm_Initialize()
Me.ScrollBars = fmScrollBarsVertical
.......

I would be very thankful if you could help me with problem! Thanks again
Tom! You save my life on a daily basis!
"Tom Ogilvy" skrev:

Or you could put this in your initialize event for the Userform:

Private Sub UserForm_Initialize()
UserForm1.ScrollBars = fmScrollBarsVertical
UserForm1.ScrollHeight = UserForm1.Height
UserForm1.Height = UserForm1.Height / 2
End Sub

This assumes in the VBE you can see the entire userform.

--
Regards,
Tom Ogilvy


"Viktor Ygdorff" wrote:

Hello! I have a user from that unfortunately has become very long. Therefore
I need a scrollbar so that the user shall be able to scroll his/her way down
to the end of the user form. I found something that looked like a scrollbar
in the tools for the user form but I do not know how to write code for it and
my help function for vba does not work. Please if you know how to write code
for this, help me out! Thank you!



All times are GMT +1. The time now is 02:36 AM.

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