dynamic text box location on userform

maxx_daddy

Board Regular
Joined
Dec 3, 2010
Messages
74
hi all,
I have a userform that has 19 textboxes on it. I would like to enlarge the textbox when entered so as to give enough room to type a multi line answer as needed. My question is.... is there a way to reposition the text boxes below the active text box dynamically, say based on the top or bottom of the textbox above? otherwise the only way I can see to do this is this
Code:
Private Sub TextBox1_Enter()    With TextBox1
    .Top = 5
    .Height = 100
    End With
    With TextBox2
    .Top = 110
    .Height = 20
    End With
    With TextBox3
    .Top = 135
    .Height = 20
    End With
    With TextBox4
    .Top = 160
    .Height = 20
    End With
    With TextBox5
    .Top = 185
    .Height = 20
    End With
     With TextBox6
    .Top = 210
    .Height = 20
    End With
    With TextBox7
    .Top = 235
    .Height = 20
    End With
    With TextBox8
    .Top = 260
    .Height = 20
    End With
    With TextBox9
    .Top = 285
    .Height = 20
    End With
    With TextBox10
    .Top = 310
    .Height = 20
    End With
    With TextBox11
    .Top = 335
    .Height = 20
    End With
     With TextBox12
    .Top = 360
    .Height = 20
    End With
    With TextBox13
    .Top = 385
    .Height = 20
    End With
    With TextBox14
    .Top = 410
    .Height = 20
    End With
    With TextBox15
    .Top = 435
    .Height = 20
    End With
    With TextBox16
    .Top = 460
    .Height = 20
    End With
    With TextBox17
    .Top = 485
    .Height = 20
    End With
    With TextBox18
    .Top = 510
    .Height = 20
    End With
     With TextBox19
    .Top = 535
    .Height = 20
    End With
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    With TextBox1
    .Height = 20
    End With
End Sub
for every textbox.
thanks for looking,

Maxx_daddy (Maxx's daddy)
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
If you put the TextBoxes in a frame with a vertical scroll you could perhaps increase the size of each box to take the Input Data, and scroll through them as required.
Just an Idea !!!!!
 
Upvote 0
If you put the TextBoxes in a frame with a vertical scroll you could perhaps increase the size of each box to take the Input Data, and scroll through them as required.
Just an Idea !!!!!

that is a great idea, however for this project the inevitability is it will end up on a microsoft surface tablet and will be used out in the field for my job. the idea is to be able to see all of the tb's at a glance, but when you enter into one of the tb's it blows up (so you can voice to text in a paragraph of notes, of course) I am trying to keep all the data on a 10" screen. thanks again :)
 
Upvote 0
Something like (I only added the enter event of the first 4 textboxes, you get the idea):

Code:
Sub RepositionAll(oCurCtl As Control)
    Dim oCtl As Control
    Dim bPast As Boolean
    Dim sHeight As Single
    For Each oCtl In Me.Controls
        If LCase(TypeName(oCtl)) = "textbox" Then
            If oCtl.Name <> oCurCtl.Name Then
                sHeight = sHeight + 45
                oCtl.Height = 25
            Else
                oCtl.Height = 100
                sHeight = sHeight + 45
            End If
            oCtl.Top = sHeight + 25
            If oCtl.Name = oCurCtl.Name Then
                sHeight = sHeight + 100
            End If
        End If
    Next
End Sub

Private Sub TextBox1_Enter()
    RepositionAll TextBox1
End Sub

Private Sub TextBox2_Enter()
    RepositionAll TextBox2
End Sub

Private Sub TextBox3_Enter()
    RepositionAll TextBox3
End Sub

Private Sub TextBox4_Enter()
    RepositionAll TextBox4
End Sub
 
Upvote 0
Reminds me of the Samsung commercial (poking fun at the i-phone) where the guys mind was blown.......... yeah, that's me, right now. Amazing work........ and thank you.
Joe
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

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