Smart Lookup

mrroland

Active Member
Joined
Apr 29, 2002
Messages
294
Hi,

I don't know if this is possible in excel but I will give it a try. Just have a look at this. Column A and B are from a clean source, Column C is the output that I am looking for. Problem is with the data that has arrived that there is a great variation in the way that the models are described. A simple index with match function as seen in cell G3 doesn't work. Basically I need a lookup that will only look at the letters and doesn't look at spaces or digits. The combination of letters is variable and can include all letters from A to Z
Book1.xls
ABCDEFGH
1ThisistheCleanSource000Output0
2EquipmentModelConfigurationEquipmentModelConfiguration0
3IMODELAVALTVFSRotaryScrewIMODELAVALTVFSRotaryScrew0
40000IMODELAVALTVFS2000
50000IMODELAVAL4TVFS2000
60000IMODELAVAL4TVFS2000
700000000
Sheet1


I hope this makes sense and you lot can help me here,
Cheers,
Roland
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
This may indeed be possible with a native excel function.... but for now, using the following UDF, say in column G, and using the results for your INDEX MATCH would appear to work for my small test.

It converted data such as

TVFS 200
TVFS 201
TVFS 202
TVFS 203
4TVFS 204
TVFS 205
TVFS


to this

TVFS
TVFS
TVFS
TVFS
TVFS
TVFS
TVFS

and I think that was what you were getting at (?)

Here is the FUNCTION code... you can place it in a standard module

Code:
Function StripTheLetters(stdText)
'strips the Letters from a text string containing numbers
Dim strLetters As String

stdText = Trim(stdText)
strLetters = ""
For i = 1 To Len(stdText)
    If IsNumeric(Mid(stdText, i, 1)) = False Then
        strLetters = strLetters & Mid(stdText, i, 1)
    End If
Next i
StripTheLetters = strLetters
End Function

I am sure someone else will probably improve on my clunky workaround :rolleyes: hope it helps anyhow
 
Upvote 0
Hi,

I did a formula aproach but as it is a little complex, maybe WillR's suggestion is to prefere.

I post it anyway so you can choose.
Book1
ABCDEFGHI
1
2IMODELAVALTVFSRotaryscrewIMODELAVAL4TVFS2004200TVFSRotaryscrew
3IMODELAVALTVSFSomethingelseIMODELAVALTVFS200#N/A200TVFSRotaryscrew
4IMODELAVALTFVSYetanotherthingIMODELAVALTFVS#N/A#N/ATFVSYetanotherthing
5IMODELAVAL555TVSF444555444TVSFSomethingelse
6IMODELAVAL5TVSF555TVSFSomethingelse
7IMODELAVAL555TVSF555#N/ATVSFSomethingelse
8IMODELAVALTVSF447#N/A447TVSFSomethingelse
9
10
Sheet1
 
Upvote 0
WillR,

Thanks for your reply. The output of your FUNCTION is certainly what I am looking for :biggrin:. The only problem is my knowledge of VBA. if i past your code into a standard module it doesn't seem to work for me. I moved the output configuration column to column H. but if I do run macro it says: compile error. expected end sub. Is the function not a macro? What does UDF mean?

What am i doing wrong. :confused:

Cheers
 
Upvote 0
UDF stand for "User Defined Function" and it works like a formula not a macro

If you have pasted it in a standard module you should be able to use

=StripTheLetters(A1)

to remove the numbers and spaces from the string in A1
change to suit.

Edit:
If you pasted it in your personal.xls then you will need to do
=PERSONAL.XLS!StripTheLetters(A1)
 
Upvote 0
Will,

Actually there is still one thing that needs to be added to this UDF. The result of the function does return the exact thing i need but unfortunately it still includes spaces and the index match formula doesn't like that. Now I can get around this by adding another column and use a trim formula but I think the UDF can also do this. As I said my knowledge of VBA is nonexistend so I apologize for this simple request.

Cheers,
Roland
 
Upvote 0
If you don't know how to do it in the code you could always:

=SUBSTITUTE(StripTheLetters(A1)," ","")
 
Upvote 0
I added Trim() to the last line - it should now just return the letters.

Code:
Function StripTheLetters(stdText)
'strips the Letters from a text string containing numbers
Dim strLetters As String

stdText = Trim(stdText)
strLetters = ""
For i = 1 To Len(stdText)
    If IsNumeric(Mid(stdText, i, 1)) = False Then
        strLetters = strLetters & Mid(stdText, i, 1)
    End If
Next i
StripTheLetters = Trim(strLetters)
End Function

HTH
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,314
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top