Reputation: 399
My text box in VBA, by default scrolls to the bottom. I dont want this. I want the scroll bar to remain at the top when the userform displays.
Solution?
Upvotes: 2
Views: 5024
Reputation: 21
In the UserForm's Initialize event, you can use textbox1.curline=0
Private Sub UserForm_Initialize()
TextBox1.SetFocus ' to make next line work, first we must set focus on Textbox
TextBox1.CurLine = 0
End Sub
Upvotes: 1
Reputation: 149305
In the UserForm's Initialize
event, set the starting point of the cursor to TextBox's start using .SelStart
For example.
Private Sub UserForm_Initialize()
Dim sSample As String
Dim i As Long
For i = 1 To 10
sSample = sSample & "Blah Blah" & i & vbNewLine
Next i
TextBox1.Text = sSample
'~~> Set to starting point
TextBox1.SelStart = 0
End Sub
Upvotes: 4