VBA: right of a character and include that character

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
771
Hello, small problem:

Code:
Right(elem.innerText, Len(elem.innerText) - InStrRev(elem.innerText, " / "))
This successfully pulls right of the "/". How would I adapt to include the "/" as well?

Thanks.
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,080
Office Version
365
Platform
Windows
I presume those spaces arent meant to be there around the " / " in your code? You could just add 1 eg

Code:
Right(elem.innerText, Len(elem.innerText) - InStrRev(elem.innerText, "/") + 1)
or use mid which is a bit easier

Code:
Mid(elem.innerText, InStrRev(elem.innerText, "/"), Len(elem.innerText))
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,926
Office Version
2010
Platform
Windows
or use mid which is a bit easier

Code:
Mid(elem.innerText, InStrRev(elem.innerText, "/")[B][COLOR="#FF0000"], Len(elem.innerText)[/COLOR][/B])
The Mid function (in VBA) is even easier to use for the OP's request... you can leave off what I highlighted in red and it will still work the same... the Mid function returns out to the end of the text when the 3rd argument is omitted (I wish Excel's MID function did that).
 

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,080
Office Version
365
Platform
Windows
The Mid function (in VBA) is even easier to use for the OP's request... you can leave off what I highlighted in red and it will still work the same... the Mid function returns out to the end of the text when the 3rd argument is omitted (I wish Excel's MID function did that).
Thanks Rick i wasnt aware of that.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,503
Messages
5,468,998
Members
406,627
Latest member
IncandenzaH1997

This Week's Hot Topics

Top