So, I often get issues like this when I grab a macro from online and I'm not sure what the problem is. It's actually a UDF and the code is pasted below, followed by a description of the error. Any ideas what the issue is here? Any help is greatly appreciated.
'This VBA code will create a function to get the numeric part from a string
Function GetNumeric(CellRef As String)
Dim StringLength As Integer
StringLength = Len(CellRef)
For i = 1 To StringLength
If IsNumeric(Mid(CellRef, i, 1)) Then Result = Result & Mid(CellRef, i, 1)
Next i
GetNumeric = Result
End Function
The error is:
Compile error:
Variable not defined
The in-code error highlighting is:
Highlights the first line in yellow (with the little arrow). And highlights the first i (on line 4)
Bookmarks