lundi 21 décembre 2020

EXtracting number in VBA while using IF - REFRESH

I want to extract a number in a String and apply this number to the IF function, but if the source row changes the If function that contains the VBA function does NOT refresh.

Exemple> Source row= 10VBA

Public Function JustNumber(ByVal vValor As String) As String
   Application.Volatile True
    
    Dim vQtdeCaract As Long
    Dim vControle   As Boolean
    
    vQtdeCaract = Len(vValor)
    vControle = False
    
    For i = 1 To vQtdeCaract
        
        If IsNumeric(Mid(vValor, i, 1)) Then
            If vControle = True And JustNumber <> vbNullString Then
                JustNumber = JustNumber + "/"
            End If
            vControle = False
            JustNumber = JustNumber & Mid(vValor, i, 1)
        Else
            vControle = True
        End If
    Next
End Function

returns the number 10

=IF(JustNumber(source row)=10;"True";"False")

Returns "True"

But, if I change the source row the IF fuction doesn't change, there is a way to refresh the function after the change in the Source row to 15VBA, making the function = "False" ?

Aucun commentaire:

Enregistrer un commentaire