B
bsimecek
I am trying to put together a formula that will find the longest word i
a cell. The cell in question will have a sentance like structure.
have a VBA sub that will do it, but I need to find a formula that wil
do the same.
The VBA is:
Function LongestWord(str) As String
' Returns the longest word in a string of words
Dim x As Variant
Dim i As Long
str = Application.Trim(str)
x = Split(str, " ")
LongestWord = x(0)
For i = 1 To UBound(x)
If Len(x(i)) > Len(LongestWord) Then
LongestWord = x(i)
End If
Next i
End Function
Does anyone have an idea
a cell. The cell in question will have a sentance like structure.
have a VBA sub that will do it, but I need to find a formula that wil
do the same.
The VBA is:
Function LongestWord(str) As String
' Returns the longest word in a string of words
Dim x As Variant
Dim i As Long
str = Application.Trim(str)
x = Split(str, " ")
LongestWord = x(0)
For i = 1 To UBound(x)
If Len(x(i)) > Len(LongestWord) Then
LongestWord = x(i)
End If
Next i
End Function
Does anyone have an idea