Creating a scrollbar within an item that was created during runtime

raven1124

New Member
Joined
Jun 13, 2017
Messages
29
Hello Everyone,

I have few questions here

1. Just like what is in the subject line, I would like to learn how can I add a scrollbar within a frame that I created as well. Please see the code I created so that I can explain it further.

Code:
For counter = 0 To 10
        
        Set MyFrame= Userform1.Controls.Add("Forms.Frame.1")
            With MyFrame
                .Name = "MyFrame" & counter
                .Caption = ""
                .Top = 10
                .Left = 5 * 100 * counter
                .Width = 100
                .Height = 50
            End With	




	For counter2 = 0 to 4
		'This line is where I'm having problem with fixing
                Set MyScrollBar= MyFrame & .Controls.Add("Forms.ScrollBar.1")
                        With MyScrollBar
                            .Top = MyFrame & counter + 100 + 40 * counter2
                            .Left = 5 + 105 * counter
                            .Width = 100
                            .Height = 15
                            .Min = 0
                            .Max = 5
                        End With
	Next counter2


Next counter

2. How can I create a code for whenever I change the current value of my scrollbar to reflect inside a labelbox?

Note: Every item here was created during runtime, hence I cannot create a code for each scrollbar as it can easily get adjusted.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try removing the ampersand (&) . . .

Code:
[COLOR=#333333]Set MyScrollBar= MyFrame.Controls.Add("Forms.ScrollBar.1")[/COLOR]
 
Upvote 0
Hello, Sorry for the delayed response, I actually did it initially but it didn't add to the succeeding scrollbars
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top