Hello cdafonseca,
The problem looks like a referencing problem. By default, VBA variables are passed by Reference. This means the variable being must already be declared. If VBA discovers the variable has not been declared then an error occurs. The other method of referencing is by Value. VBA basically creates a copy of the variable to use in the procedure. Try the change below and see if it fixes your problem.
Function REMOVE_RIGHT_SIDE(ByVal MySTRING As String) As String
Dim IFOUND As Integer
Dim I As Integer
IFOUND = 0
For I = Len(MySTRING) To 1 Step -1
If ((Mid(MySTRING, I, 1) = " ") And (IFOUND = 0)) Then IFOUND = I: Exit For
Next I
If (IFOUND <> 0) Then REMOVE_RIGHT_SIDE = Left(MySTRING, IFOUND - 1)
End Function
Bookmarks