Right vba function
I want to take everything to the right of a character in a string I used
Right(enclosedValue, InStr(enclosedValue, "*") - 0)
where is the private value 29,6 *60
, so I need to return *60
, but now it returns
,6 *60
Sorry if this question has already been asked, I have just started using vba and I am a little confused
source to share
If you must use Right
:
Right(enclosedValue, Len(enclosedValue) - InStr(enclosedValue, "*"))
Indeed, Mid
this is the way to keep the code short and readable.
source to share
The fastest way to do this is to use it Right
as a string function Right$
. See here
The biggest gain is achieved with a string function (i.e. Mid$
much superior Mid
)
Descending order:
-
Right$(StrIn, Len(StrIn) - InStr(1, StrIn, "*") + 1)
-
Mid$(StrIn, InStr(1, StrIn, "*"))
-
Mid(StrIn, InStr(1, StrIn, "*"))
source to share