Answers for "vba text max line length"

VBA
0

vba text max line length

' Max line length inside a text
Public Function MaxLineSize(ByVal pText As String)
    Dim lines() As String
    Dim line As Variant
  lines = Split(pText, vbCrLf)
    If UBound(lines) - LBound(lines) + 1 = 0 Then Exit Function
    For Each line In lines
        MaxLineSize = Application.Max(MaxLineSize, Len(line))
    Next line
End Function
'--------------------------------------------------------------
Sub TestMe()
	Dim test As String
    test = "aa" & vbCrLf & "bbbbbb"
    MsgBox MaxLineSize(test)       ' 6
End Sub
Posted by: Guest on February-12-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language