Hi Faycal
Try replacing:
TextBox1.SelStart = 0
with
TextBox1.SetFocus
TextBox1.CurLine = 0
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a textbox with a verticals scrollbar.
I want the scroll bar to remain at the top at start.
So that when users click inside the text box, it doesn't scroll to the bottom of the text, which is what is currently happening.
'
I found this online but don't know how to implement:
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
Not sure this works or where to find the Initialize event...
If someone can help,
Thanks,
Faycal
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Hi Faycal
Try replacing:
TextBox1.SelStart = 0
with
TextBox1.SetFocus
TextBox1.CurLine = 0
Set the EnterFieldBehavior property of the TextBox to fmEnterFieldBehaviorRecallSelection
https://docs.microsoft.com/en-us/office/vba/lan...
Andreas.
Thanks Andreas,
I will try.
Thanks Dave,
I will see if that works.
Best
Faycal
Hi Dave,
I m still having the same issue.
Code doesn't seem to work or maybe I m not editing correctly.
following all the code I have added to my app:
Private WithEvents app As Application
Private Sub app_WorkbookOpen(ByVal Wb As Workbook)
For Each Sheet In ActiveWorkbook.Worksheets
Sheet.Select
Range("A1").Select
Next
app.Goto Wb.Worksheets(1).Range("A1")
app.ScreenUpdating = True
End Sub
Private Sub Workbook_Open()
Set app = Application
End Sub
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
TextBox1.SetFocus
TextBox1.CurLine = 0
End Sub