Returning end letters

papasmurfuo9

Registered User.
Local time
Yesterday, 21:21
Joined
May 28, 2014
Messages
69
Hi
I only wanna return what ive highlighted bold before, so top one, g ea

Excel i use this

IFERROR(TRIM(REPLACE(SUBSTITUTE(L2,"" x "",""""),1,FIND("" "",SUBSTITUTE(L2,"" x "","""")),"""")),"""")

Qry_Range_File_Master
Sales conversion text
1 x 1 x 24 x 250 g ea
1 x 1 x 1 x 2 Kg ea
1 x 1 x 30 x 250 g ea
1 x 1 x 1 x 4 Kg ea

many thanks in advance!
 
this is not tested

on your query:

OUM:GetUOM([Sales Convertion Text])

put this in a module
Code:
Public Function GetUOM(strMeasure As String) As String
    Dim strReturn As String
    Dim intStringLen As Integer
    Dim intLoop As Integer
    Dim strChar As String

    strMeasure = Trim(strMeasure)
    intStringLen = Len(strMeasure)
    If intStringLen > 0 Then
        For intLoop = intStringLen To 1 Step -1
            strChar = Mid(strMeasure, intLoop, 1)
            If IsNumeric(strChar) Then Exit For
            strReturn = strChar & strReturn
        Next
    End If
    GetUOM = strReturn
End Function
 
To avoid a leading blank code
GetUOM = mid(strReturn,2)

Brian
 
Last edited:
Also, more simply . . .
Code:
Function GetUOM(Measure as String) as String
   GetUOM = Trim(Right(Measure, 5))
End Function
. . . as another idea.
 

Users who are viewing this thread

Back
Top Bottom