VBA Lookup Help

quickc2

New Member
Joined
Jun 20, 2017
Messages
22
Hi, any help would be greatly appreciated.

I have worksheet with multiple columns of information in it with my M column containing a lot of information at once.

The information in column M always begins with "Door Surf Color:" followed by a 4-6 letter word.

I want a function that will lookup the word that follows "Door Surf Color:" and pastes it into the same row in column AT.



Thank you!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Your question isn't quite clear.

Are you simply looking to extract the word that follows "Door Surf Color:", or are you trying to match the word up to something?
If the later, what are you trying to match it up to, and what are you wanting to return?

An actual example may help clarify what you are after.
There are tools you can use to post screen images. They are listed in Section B of this link here: http://www.mrexcel.com/forum/board-a...forum-use.html.
Also, there is a Test Here forum on this board that you can use to test out these tools to make sure they are working correctly before using them in your question.
 
Upvote 0
Hi, thanks for the reply.

For example, if my cell M2 begins "Door Surf Color:GK_26 Window blind..." I want to be able to copy the 'GK_26' and paste it into the same row in the AT column (AT2). The small deviance is in the amount of letters is in the code so the macro must be able to do codes that are different lengths.
 
Upvote 0
Do you really need VBA, or can you just use a formula like this:
Code:
=TRIM(LEFT(SUBSTITUTE(SUBSTITUTE(M2,"Door Surf Color:","")," ",REPT(" ",100)),100))
 
Upvote 0
We could create a simple User Defined Function in VBA to do this, like this:
Code:
Function GetValue(myString As String) As String

    Dim temp As String
    Dim arr1() As String
    Dim arr2() As String
    
    arr1 = Split(myString, ":")
    arr2 = Split(arr1(1), " ")
    
    GetValue = arr2(0)

End Function
Then you could use this User Defined Function either on the sheet directly, or in VBA, i.e.
Code:
=GetValue(M2)
(on the sheet)
 
Last edited:
Upvote 0
That is perfect! Thank you. I was overthinking it with a VBA but had not used these functions before. You learn something new everyday.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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