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"

[TABLE="width: 168"]
<colgroup><col span="2"></colgroup><tbody>[TR]
[TD]Column O[/TD]
[TD]Column P[/TD]
[/TR]
[TR]
[TD]Donation
[/TD]
[TD]Donations[/TD]
[/TR]
[TR]
[TD]salary[/TD]
[TD]Salaries[/TD]
[/TR]
[TR]
[TD]Commerce
[/TD]
[TD]Legalization
[/TD]
[/TR]
[TR]
[TD]Housing
[/TD]
[TD]Housing Allow.
[/TD]
[/TR]
[TR]
[TD]Bank[/TD]
[TD]Bank Charges[/TD]
[/TR]
[TR]
[TD]GSM[/TD]
[TD]Communications[/TD]
[/TR]
[TR]
[TD]Stamp[/TD]
[TD]Legalization[/TD]
[/TR]
[TR]
[TD]Trip[/TD]
[TD]Business Trip[/TD]
[/TR]
[TR]
[TD]Chamber[/TD]
[TD]Legalization[/TD]
[/TR]
</tbody>[/TABLE]


Thanks,
Imran.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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