This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

I need to extract certain data from a field. I need all the data that is after the letter "X" in my field. For example:

MOLYBDENUM-RD-0.0784-.0002X24.000

I need to extract the 24.000

It won't be the same length every time though. It could be 2.000, 100.000, etc.

How can I do this?

MOLYBDENUM-RD-0.0784-.0002

I need to extract the 24.000

It won't be the same length every time though. It could be 2.000, 100.000, etc.

How can I do this?

Formula:

=RIGHT(A1,LEN(A1)-FIND("X"

VBA:

Sub GetData()

Dim sVal As String, rCell As Range

Set rCell = ActiveCell 'change to suit

sVal = Right(rCell.Value, Len(rCell.Value) - InStrRev(rCell.Value, "X"))

MsgBox sVal

End Sub

Zack

If pos > 0 Then

ResultStr = Mid(FIELDNAME,(pos+1))

Else

ResultStr = ""

End If

Is that what you're looking for?

Your formula works but one thing. If it doesn't find an "X" in my cell how can I have it just put a 0 as my result instead of getting the #Value! error?

=IF(ISERROR(FIND("X",A2,1)

Zack

Also, what if I just want the values to the right of the X and only up to the decimal point? I don't think I will need any values after the decimal point.

Do you mean you would only then want "24" from your example?

Zack

=IF(FIND("X",A2,1)<>0,--RI

And in both of these last two examples I moved the data into A2 instead of A1, which is why my formulas have different references. Sorry for any confusion.

Zack

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

=IFERROR(--RIGHT(A2,LEN(A2

It's a nifty way of taking a number as text, and making it into an actual number. That is the double urnary. You could also use 1* or 0+ with the same effect.

Zack