VBA - VLookup and Replace InStr


I have this Excel file with two sheets in it.
Sheet 1 and DBASE.

In Sheet1 column C, i will have multiple values inside the cells. They are called Options.
In Sheet DBASE, i will have the same distinct single Options values in column M and in column N i will have the Option description.

My goal is to replace in Sheet1 column C all the Options by the Option Descriptions from the DBASE sheet.

I started to build something but i just can make it right now.

Here is the code.
 Dim Question As Range
    Dim Found As Range
    Dim rngSearch As Range
    Dim ws1 As Worksheet, ws2 As Worksheet
    Set ws1 = Sheets("DBASE")   'User's answers sheet
    Set ws2 = Sheets("Sheet1")   '
    Set rngSearch = ws1.Range("M:M")    'Users questions
    Application.ScreenUpdating = False
    For Each SearchValue In ws2.Range("c1", ws2.Range("c" & Rows.Count).End(xlUp))
        If Not IsEmpty(SearchValue) Then
            Set Replace_By = rngSearch.Find(What:=SearchValue, _
                                       LookIn:=xlValues, _
                                       LookAt:=xlWhole, _
                                       SearchOrder:=xlByRows, _
                                       SearchDirection:=xlNext, _
            If Not Replace_By Is Nothing Then
                If InStr(SearchValue.Offset(, 0).Value, Replace_By.Offset(, 0).Value) Then
                  SearchValue.Offset(, 0).Value = Replace(SearchValue.Offset(, 0).Value, SearchValue.Offset(, 0).Value, Replace_By.Offset(, 1).Value)

                End If
                Set Replace_By = Nothing
            End If
        End If
    Next SearchValue
    Application.ScreenUpdating = True

Open in new window

How can i do this? Can it be done with a code that would also run faster than the approach i'm taken?

Thanks for your help
LVL 11
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ejgil HedegaardCommented:
Try attached.
The code load the ranges to arrays in VBA, handle the search there, and write the result back to sheet when done.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ejgil HedegaardCommented:
Another method could be a VBA function.
Simpler, not as fast, but more flexible, because the ranges are selected in the function arguments.
See column G.
Wilder1626Author Commented:
Thank you Ejgil Hedegaard. I will go with this option. It does exactly what i wanted.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.