Partially search through a column and return corresponding value in another column

imran1059

Board Regular
Joined
Sep 28, 2014
Messages
112
Hi,

I need to put a formula in Column M which will search through column L and match it (partially or completely) with column O and display the value available in same row in column P. If VBA code will do it faster then provide VBA code please.

e.g. in Column L, it is written as "Salary of Emp#784" so in Column M it should be just "Salaries"

Column OColumn P
Donation
Donations
salarySalaries
Commerce
Legalization
Housing
Housing Allow.
BankBank Charges
GSMCommunications
StampLegalization
TripBusiness Trip
ChamberLegalization

<colgroup><col span="2"></colgroup><tbody>
</tbody>


Thanks,
Imran.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try:
Code:
Sub FindMatch()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range, foundRng As Range
    For Each rng In Range("O2:O" & LastRow)
        Set foundRng = Range("L:L").Find(rng, LookIn:=xlValues, lookat:=xlPart)
        If Not foundRng Is Nothing Then
            Range("M" & foundRng.Row) = rng
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi,

I'm a little confused with your description, something like this:


Book1
LMNOP
1Salary of Emp#784SalariesDonationDonations
2Emp#888 made a donationDonationssalarySalaries
3Company field tripBusiness TripCommerceLegalization
4HousingHousing Allow.
5BankBank Charges
6GSMCommunications
7StampLegalization
8TripBusiness Trip
9ChamberLegalization
Sheet386
Cell Formulas
RangeFormula
M1=LOOKUP(2,1/SEARCH(O$1:O$9,L1),P$1:P$9)


Formula copied down.
 
Upvote 0
Dont know why but this code is not giving me desired output. My problem is solved with the formula provided by jtakw. Anyway, thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

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