Here is my code as text:
Function NurZahl(ByVal Text As String) As Long
Dim i%, tmp
Dim Val As String
For i = 1 To Len(Text)
Val = Mid(Text, i, 1)
If(OR(IsNumeric(Val),Val=","),TRUE, FALSE) Then tmp = tmp & Mid(Text, i, 1)
Next i
NurZahl = tmp
End Function
Complete Beginner here:
Got the solution now with your help (thanks to everyone who replied) - I wanted to extract a number with decimal from a string:
Function CleanString(strIn As String) As String
Dim objRegex
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
.Global = True
.Pattern = "[^\d,]+"
CleanString = .Replace(strIn, vbNullString)
End With
End Function
The "If" line is written like an Excel formula. This is what is should look like in basic.
If IsNumeric(Val) Or Val = "," Then tmp = tmp & Mid(Text, i, 1)
The red text is a syntax error. If you go to the Debug menu and click Compile VBA Project, you'll get the error message.
The link that you included is for functions that are typed into a cell. You need a VBA reference. Here's a link to MS's reference, but a decent book would make your life a lot easier. Just search for "Excel VBA".