ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   not urgent (https://www.excelbanter.com/excel-programming/340105-not-urgent.html)

Gary''s Student

not urgent
 
I need a UDF that will return the underlined part of a text string. For
example, if cell A1 contains the string "hello world" and "world" is
underlined, then UnderCap(A1) would return "world"
--
Gary''s Student

Bob Phillips[_6_]

not urgent
 
Function WhatIsUnderlined(inp)
Dim sTemp As String
Dim i As Long
WhatIsUnderlined = ""
If TypeOf inp Is Range Then
If inp.Count = 1 Then
sTemp = inp.Value
Else
WhatIsUnderlined = "#Too many cells"
Exit Function
End If
Else
WhatIsUnderlined = "#Wrong argument type"
End If

For i = 1 To Len(inp)
If inp.Characters(i, 1).Font.Underline = 2 Then
WhatIsUnderlined = WhatIsUnderlined & Mid(sTemp, i, 1)
End If
Next i

End Function


--
HTH

Bob Phillips

"Gary''s Student" wrote in message
...
I need a UDF that will return the underlined part of a text string. For
example, if cell A1 contains the string "hello world" and "world" is
underlined, then UnderCap(A1) would return "world"
--
Gary''s Student




Gary''s Student

not urgent
 
Thank you Bob!!

Your approach can also be adapted to other special font characteristics
--
Gary''s Student


"Bob Phillips" wrote:

Function WhatIsUnderlined(inp)
Dim sTemp As String
Dim i As Long
WhatIsUnderlined = ""
If TypeOf inp Is Range Then
If inp.Count = 1 Then
sTemp = inp.Value
Else
WhatIsUnderlined = "#Too many cells"
Exit Function
End If
Else
WhatIsUnderlined = "#Wrong argument type"
End If

For i = 1 To Len(inp)
If inp.Characters(i, 1).Font.Underline = 2 Then
WhatIsUnderlined = WhatIsUnderlined & Mid(sTemp, i, 1)
End If
Next i

End Function


--
HTH

Bob Phillips

"Gary''s Student" wrote in message
...
I need a UDF that will return the underlined part of a text string. For
example, if cell A1 contains the string "hello world" and "world" is
underlined, then UnderCap(A1) would return "world"
--
Gary''s Student





Bob Phillips[_6_]

not urgent
 
Even better Gary ;-)

Bob

"Gary''s Student" wrote in message
...
Thank you Bob!!

Your approach can also be adapted to other special font characteristics
--
Gary''s Student


"Bob Phillips" wrote:

Function WhatIsUnderlined(inp)
Dim sTemp As String
Dim i As Long
WhatIsUnderlined = ""
If TypeOf inp Is Range Then
If inp.Count = 1 Then
sTemp = inp.Value
Else
WhatIsUnderlined = "#Too many cells"
Exit Function
End If
Else
WhatIsUnderlined = "#Wrong argument type"
End If

For i = 1 To Len(inp)
If inp.Characters(i, 1).Font.Underline = 2 Then
WhatIsUnderlined = WhatIsUnderlined & Mid(sTemp, i, 1)
End If
Next i

End Function


--
HTH

Bob Phillips

"Gary''s Student" wrote in

message
...
I need a UDF that will return the underlined part of a text string.

For
example, if cell A1 contains the string "hello world" and "world" is
underlined, then UnderCap(A1) would return "world"
--
Gary''s Student








All times are GMT +1. The time now is 12:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com