Resize Scrollbar with VBA

stirlingmw1

Board Regular
Joined
Jun 17, 2016
Messages
53
Office Version
  1. 2016
  2. 2013
  3. 2010
  4. 2007
Platform
  1. Windows
Morning All
I have the following code that adds another Textbox to the Userform Frame. I am trying to add a Scrollbar to this frame that firstly appears if the added textboxes drop off the bottom of the Frame (Frame height 400) and then increase in height every time a new textbox is added thereafter. An

VBA Code:
Private Sub CommandButton48_Click()
Static i, o As Integer
Dim txtbox As Object
Dim lbl As Object
   
     Set txtbox = Frame10.Controls.Add("Forms.TextBox.1")
     Set lbl = Frame10.Controls.Add("forms.Label.1")
   
i = i + 1
    With txtbox1
            .Name = "checkName" & i
            .Left = 30
            .Height = 15.75
            .Width = 60
            .Top = 26 + (15.75 * i)
        End With
o = 1 + o
    With lbl
            .Name = "checkLbl" & o
            .Left = 6
            .Height = 15.75
            .Width = 13.5
            .Top = 26 + (15.75 * o)
            .Caption = 0 + o
            .TextAlign = fmTextAlignCenter
        End With
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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