VB find two columns

ericlch16

Active Member
Joined
Nov 2, 2007
Messages
313
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
I have two columns.. when both columns are combined they are unique. so let say

Sheet1 I have:-
colA colB colC
1 2 AA
2 3 BB
1 4 CC
3 4 DD
2 5 DD

Sheet2 I have
ColA ColB Colc
1 4
3 5
2 5


usually i did this for sheet2

do loop until rngrow is > lastrow of sheet1
Set rngrow = .Find(What:=sapnotosearch, _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rngrow Is Nothing Then
if col b of sheet 1 = colb of sheet 2 then
*perfect match*
else
*only column A matches.. col b does not match*
end if
else
*col A does not match*
end if
end loop

Is there a better way to do it? i dont like the idea of have to loop until lastrow. is there any function i can do so that the .Find function can match two column do something otherwise do nothing???

How to do a search without looping by matching 2 columns? i can pass two arguments to the .Find function??
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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