So currently my VBA code looks like this:
Sub Testing()
Dim K As Long
Dim LR As Long
LR = Cells(Rows.Count, 1).End(xlUp).Row
For K = 2 To LR
Cells(K, 2).Value = StripAfter(Cells(K, 1), "_", 6)
Next K
End Sub
Function StripAfter(ByVal txt As String, ByVal delimiter As String, ByVal
occurrence As Long) As String
Dim x As Variant
x = Split(expression:=txt, delimiter:=delimiter, limit:=occurrence + 1)
StripAfter = x(UBound(x))
End Function
I have this linked to a button that will output the data like this:
(Side note: Column A is pasted in, Column B is the result after having the VBA Macro run)
With this output it's exactly what the formula is made to do which is great! My question is and I can't wrap my head around this (I'm new with VBA Macros, trying to learn as best as I can) for the results in Column B, they all end in numbers with an X
between the numbers. How would I adjust my code to make it so it deletes that portion of text? So the result would look like:
As you can see from the results I'm looking for compared to the results that are given, the ###X###
is taken out at the end. I've played around outside of VBA and found this to work but its essentially a two step process:
=RIGHT(SUBSTITUTE(A1,"_",CHAR(10),12),LEN(A1)-FIND(CHAR(10),SUBSTITUTE(A1,"_",CHAR(10),12),1)+1)
^^^ This will grab the last section of the string from A1 (First image)
=LEFT(A20,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A20&"0123456789")) -1)
^^^ (A20 is the cell I used from the formula above to grab the last section of the string in A1) And this will delete anything after the very first number. This works exactly how I want it too, but I have no idea where to begin to implement this in the VBA Formula above.
Any help would be greatly appreciated!