I am writing a macro in Excel where I need to get a substring from a String.
It’s like this.
~/tester/test/hai/bye
~/stack/overflow/hai/bye
In the above cases I need to take the String tester from the first one and stack from the second one. I tried using InStr but it’s not useful. Can anyone help?
You can do this using the InStr and Mid functions.
Use the InStr function to find the occurrences of the / and then use Mid to get the part of the string that you are interested in.
Try this:
This function will produce the desired results.