Try this:
Array created listing everything to be removed
- VBA removes everything listed in array
- so you could add other dimensions (eg "r" for radius etc)
- just be careful not to remove letters "P" or "I" (or Pi will complain!)
- adding the "=" moved to the end for obvious reason!
Function REMOVETEXT(myStr As String)
Dim remove()
remove() = Array(" ", "=", "Dia", "h", "[", "]")
For a = LBound(remove) To UBound(remove)
myStr = Replace(myStr, remove(a), "")
Next a
myStr = "=" & Replace(myStr, "Pi", "Pi()")
REMOVETEXT = Evaluate(myStr)
End Function
Bookmarks