| re: Extracting data from a line in field with written text
dear,
I have refined the function.
Now you can select any line in a text.
========================================
Option Explicit
'§ !!!! To add a HELPtext to a function:
'§ Open the "Object Browser" (F2) in VBA
'§ Search the function.
'§ RMB - "Properties".
'§ Enter text in "Description"
Public Function TextLine(TextCell As Range, LineNumber As Integer) As String
Dim REST_TEXT As String
Dim i As Integer
'§ cut lines
REST_TEXT = TextCell
For i = 1 To LineNumber - 1
If InStr(REST_TEXT, Chr(10)) Then '§ if there is a linefeed
REST_TEXT = Mid(REST_TEXT, InStr(REST_TEXT, Chr(10)) + 1)
Else '§ LineNumber to big
REST_TEXT = "No line"
End If
Next
'§ capture line = first line in rest string
If InStr(REST_TEXT, Chr(10)) Then '§ if not last line
TextLine = Left(REST_TEXT, InStr(REST_TEXT, Chr(10)) - 1)
Else '§ last line
TextLine = REST_TEXT
End If
End Function
================================================== =======
See also attachment.
br,
|