excel - vba - userform - frame - set scrollbar position

ramtoo picture ramtoo · Mar 4, 2013 · Viewed 11.2k times · Source

How do I set the scrollbar position of a frame(inside an userform)?

The case:

I have a frame in an userform that has dynamic content. So if the content is too big to fit the frame, it (dynamically) creates a scrollbar in that frame. The scrollbar also has dynamic values, following the frame content size.

The code that updates the scrollbar is as follows:

With userform1.frame1
    'dynamic size
    .ScrollHeight = param1 * param2
    .ScrollWidth = .InsideWidth * 30
End with

So I'd like to have something to send the scrollbar to the bottom position! How do I do that? Thanks in advance

Answer

barrowc picture barrowc · Mar 4, 2013

After setting the ScrollHeight and ScrollWidth and still inside the With block try:

.Scroll ActionX:=fmScrollActionNoChange, ActionY:=fmScrollActionEnd

More details can be found here