Resize Scrollbar with VBA

stirlingmw1

New Member
Joined
Jun 17, 2016
Messages
14
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
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Watch MrExcel Video

Forum statistics

Threads
1,127,660
Messages
5,626,148
Members
416,165
Latest member
hamburger138

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
Top