Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA macro vlookup equivalent ?

Status
Not open for further replies.

Tubby6

Technical User
Jun 4, 2007
26
CH
Hello,
I am new to VBA and have searched for various websites about comparing cells in two worksheets and displaying the rows that are different in a 3rd sheet. I can easily do this in vlookup see but I would like to do it via a command button. Other websites used integers as examples however I am comparing strings.

This is the normal vlookup in excel:

=IF(VLOOKUP(new,old,1,FALSE)=new,TRUE,FALSE)

I would like the false rows to be in a new sheet.

I tried the following but I know its very basic and I would like to get some guidance if possible.thanks in advance.


Sub StatusCheck_button()

Dim o1, n2, CSht As Worksheet
Dim Msg As String

If o1.Range("b2") <> n2.Range("b2") Then
'I would like the macro to display these in 3rd sheet'
Else
Msg = " There are currently no changes"
MsgBox Msg

End Sub


thanks - tubbz
 
You could use a Vlookup formula. Then use advanced filter (with the named ranges) to copy the data to a new sheet.
Just do the Vlookup without the IF bit. Any values not found will give a result of #n/a. Filter criteria can look for this value.

Gavin
 




Hi,

I'd probably use MS Query.

If I were going to use a formula, I do it on the sheet, more than likely.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top