I've got a fairly simple problem, |I have a string of text separated by forward slashes "/" with about 5 different things (e.g. fathead-sports/college/cfb/Michigan Wolverines)
I want to have only the last two items listed in a new cell. (e.g. cfb/Michigan Wolverines)
The macro solution provided will work fine. The only thing to be aware of is it may not work properly if there are fewer than two /'s in the string, or if there are only two /'s and the first one is the very first character.
If you just want a pure formula method, here are a couple possibilities, which depend on how many /'s your data can have:
First, I assume that the tilde (~) character will never appear in this cell. If it does, you would need to use something else that doesn't appear and substitute it for the ~ in the below formulas.
1. If you are only ever going to have 3 /'s in your cell, the following will extract only the last bit:
I've got a fairly simple problem, |I have a string of text separated by forward slashes "/" with about 5 different things (e.g. fathead-sports/college/cfb/Michigan Wolverines)
I want to have only the last two items listed in a new cell. (e.g. cfb/Michigan Wolverines)
Source Sheet: RawDate
Source Cell: U2
Result Sheet: Result
Result Cell: C2
Help please?
Here you go:
Option Explicit
Sub ParseCell()
Dim SplitText As Variant
Dim i As Integer
Dim s As String
SplitText = Split(Sheets("RawData").Cells(2, 21), "/")
i = UBound(SplitText)
s = SplitText(i - 1) & "/" & SplitText(i)
Sheets("Result").Cells(2, 3) = s
End Sub
Bookmarks