Function Result Not Being Carried Back To Calling Procedure

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,632
Office Version
  1. 365
  2. 2016
Platform
  1. 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

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
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,225,287
Messages
6,184,075
Members
453,210
Latest member
GravyG_123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top