Title explains issue. I just want to create a simple bookmark for a textbox with a large amount of text
that will enable returning to the same point (in this case verse) Last left. If the focus is lost when another ruserform
opens, or if the userform is closed and opens back up, Excel always moves to the first item in the Listbox and the Textbox
displays the first item at the top instead of where the user left off.
If a chapter of text has 48 verses, why should the user be forced to start from the first item in the Listbox every time?
and scroll all the way down to verse 35, or 40 or 42?
To me, the code to do this correctly(leave and return to the same spot left) should be in either the navigation button or the Listbox Change event..
My code for both:
The "x"'s are just placeholders on verses previously read and are in col A. I figured if I could make LastRow in col A = to
Listbox1's value, each time focus is regained and the form is active it should solve the problem.
Rowsource = RESULT!B1:G500. This changes with each chapter.
Sorry for the long post. Thanks for anyone's help. This seems simple enough. Just can't make it work.
cr
that will enable returning to the same point (in this case verse) Last left. If the focus is lost when another ruserform
opens, or if the userform is closed and opens back up, Excel always moves to the first item in the Listbox and the Textbox
displays the first item at the top instead of where the user left off.
If a chapter of text has 48 verses, why should the user be forced to start from the first item in the Listbox every time?
and scroll all the way down to verse 35, or 40 or 42?
To me, the code to do this correctly(leave and return to the same spot left) should be in either the navigation button or the Listbox Change event..
My code for both:
Code:
Private Sub cmdNEXT_Click()
Dim count As Integer
Dim n As Long
Dim LastRow As Long
n = BIBLETEXTWINDOW.ListBox1.ListIndex
LastRow = Sheets("RESULT").Cells(Rows.count, "B").End(xlUp).Offset(-1, 0).Row
If BIBLETEXTWINDOW.ListBox1.ListIndex = LastRow Then
MsgBox "At last row"
Exit Sub
Else
n = Me.ListBox1.ListCount - 1
Select Case Me.ListBox1.ListIndex
Case Is < n
Me.ListBox1.ListIndex = Me.ListBox1.ListIndex + 1
Case Else
Me.ListBox1.ListIndex = 0
End Select
End If
Dim rng As Range
Dim verse As String
Dim r As Long
verse = Me.TextBox8.value
Set rng = Sheets("RESULT").Columns("B:B").Find(What:=verse, _
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
Sheets("RESULT").Activate
ActiveSheet.Cells(1, 1).Select
ActiveCell.value = "x"
rng.Select
rng.Offset(0, -1).value = "x"
End Sub
Listbox1's value, each time focus is regained and the form is active it should solve the problem.
Code:
DISPLAYS WITH SPACES BETWEEN VERSES IN A TEXTBOX
Private Sub ListBox1_Click()
Dim n As Long
n = ListBox1.ListIndex
TextBox1.value = ListBox1.List(n, 1) _
& vbCrLf _
& vbCrLf _
& ListBox1.List(n + 1, 1) _
& vbCrLf _
& vbCrLf _
& vbCrLf + ListBox1.List(n + 2, 1) _
& vbCrLf _
& vbCrLf + ListBox1.List(n + 3, 1) _
& vbCrLf + ListBox1.List(n + 4, 1) _
& vbCrLf _
& vbCrLf + ListBox1.List(n + 5, 1) _
& vbCrLf _
& vbCrLf + ListBox1.List(n + 7, 1) _
& vbCrLf + ListBox1.List(n + 8, 1) _
& vbCrLf _
& vbCrLf + ListBox1.List(n + 9, 1) _
& vbCrLf + ListBox1.List(n + 10, 1) _
This has been a struggle for me which should be an easily solvable solution.
I just can't connect the dots to make it works as explained.
I'm not into submitting long code or a diatrible of needless rambling. But in order
for someone with greater understanding, I felt the picture needed to be explained
thoroughly (images below. hopefully will shed more light)
Private Sub ListBox1_Change()
Dim n As Long
n = Me.ListBox1.ListIndex
Textbox12.value = n
BIBLENOTE.TextBox1.value = Me.ListBox1.List(n, 5)
Me.TextBox10.value = ListBox1.List(n, 5)
Me.TextBox1.value = Me.ListBox1.List(n, 2)
Me.NIV.value = Me.ListBox1.List(n, 3)
Me.NASB.value = Me.ListBox1.List(n, 4)
Me.RSV.value = Me.ListBox1.List(n, 5)
Me.TextBox8.value = ListBox1.List(n, 0)
If TextBox10.value <> "" Then 'If BIBLENOTE.TextBox1.Value <> "" Then
TextBox10.Visible = True
Me.TextBox11.Visible = True '(display reduced size of RESULT sheet) 'False
TextBox11.Height = 248
TextBox11.Top = 187
TextBox10.Height = 139
Else
TextBox11.Height = 393
TextBox11.Top = 38
End If
End Sub
Sorry for the long post. Thanks for anyone's help. This seems simple enough. Just can't make it work.
cr