Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,632
- Office Version
- 365
- 2016
- Platform
- Windows
Another question about functions as I continue to learn by error.
In my routine, I call on a function call isunderline. The function is designed to analyse a string and return what string of characters, if any, is underlined. The string being analysed is at ws_ifm.range("C" & myrow), where myrow has been previously calculated
Coming into this line of code, 'myrow' equals 296. The function performs properly and calculates the value of ulval = "Raccoon". The problem is, the value of ulval isn't being carried back over to the calling procedure.
"ulval" is declared in my calling procedure as string.
In my routine, I call on a function call isunderline. The function is designed to analyse a string and return what string of characters, if any, is underlined. The string being analysed is at ws_ifm.range("C" & myrow), where myrow has been previously calculated
Code:
ulval = isunderline(myrow)
Coming into this line of code, 'myrow' equals 296. The function performs properly and calculates the value of ulval = "Raccoon". The problem is, the value of ulval isn't being carried back over to the calling procedure.
"ulval" is declared in my calling procedure as string.
Code:
Function isunderline(myrow As Long) As String
Dim cell As Range
Dim i As Long
Dim srch As String
Dim charCount As Long
Dim result As String
Set cell = ws_ifm.Range("B" & myrow)
srch = cell.Value
charCount = Len(srch)
result = ""
For i = 1 To charCount
If cell.Characters(i, 1).Font.Underline <> xlUnderlineStyleNone Then
result = result & Mid(srch, i, 1)
Debug.Print result
End If
Next i
ulval = result
End Function