The following code block simply takes the verse, in this case Romans 6:1 and places rows of text above and below the selection.
the first image below shows the highlighted verse, Romans 6:1, in the middle of the text. I want to change the code and,
instead of having the selected verse appear right in the middle of 60 rows(30 above, 30 below), I want the selected verse to
appear at the beginning of the selection as in image 2 below. I can't figure out how to change the code to do that correctly
Can someone please help with this ?
Thanks, cr
Code:
Sub get_multi_verse()
Dim c As Range
Dim tx As String
Dim va
Dim nv As Long
nv = 30 'how many verses before & after selected verse should be displayed ----> nv can be changed to any number which determines no. of verses above and below selected verse
With wkjv.Range("A:A")
Set c = .FIND(What:=sREF, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then
If c.Row - nv < 2 Then
va = .Cells(2).Offset(, 1).Resize(nv * 2 + 1)
Else
va = c.Offset(-nv, 1).Resize(nv * 2 + 1) 'va = c.Offset(-nv, 1).Resize(nv * 2 + 1)
End If
For Each X In va
tx = tx & vbLf & X & vbLf
Next
'text of selected verse + some verses before & after
TextBox1 = tx
Else
MsgBox "Can't find " & sREF
End If
End With
End Sub
instead of having the selected verse appear right in the middle of 60 rows(30 above, 30 below), I want the selected verse to
appear at the beginning of the selection as in image 2 below. I can't figure out how to change the code to do that correctly
Can someone please help with this ?
Thanks, cr