Hellow
I have a user defined function.
I'm trying to put it inside another function (native excel), and then drag it down, but it did not work.
I tried the 2 examples above but did not work
I have a user defined function.
I'm trying to put it inside another function (native excel), and then drag it down, but it did not work.
Code:
Sub Exp_I()
Range("D2").Formula = "=LEFT(ExtractNumber(C2);6)"
Selection.AutoFill Destination:=Range("D2:D2000"), Type:=xlFillDefault
End Sub
Code:
Sub Exp_II()
Range("D2").FormulaR1C1 = "=LEFT(ExtractNumber(RC[-1]);6)"
Selection.AutoFill Destination:=Range("D2:D2000"), Type:=xlFillDefault
End Sub
Code:
Function ExtractNumber(rCell As Range)
'Separa número de texto
Dim iCount As Integer, i As Integer
Dim sText As String
Dim lNum As String
'Written by OzGrid Business Applications
'[url=http://www.ozgrid.com]Excel Templates | Excel Add-ins and Excel Help with formulas and VBA Macros[/url]
'Extracts a number from a cell containing text And numbers.
sText = rCell
For iCount = Len(sText) To 1 Step -1
If IsNumeric(Mid(sText, iCount, 1)) Then
i = i + 1
lNum = Mid(sText, iCount, 1) & lNum
End If
If i = 1 Then lNum = CInt(Mid(lNum, 1, 1))
Next iCount
ExtractNumber = CLng(lNum)
End Function