Excel formula to VBA code

PaulCL

New Member
Joined
Jul 9, 2014
Messages
43
Hello Folks,
Can anyone convert this excel formula to VBA.

=IF(ISNA(VLOOKUP(A2,'Original BHHS List'!$A$1:$A$84,1,FALSE)), "Not Duplicate", "Duplicate")

Tks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Trebor76

Well-known Member
Joined
Jul 23, 2007
Messages
5,129
This will put the formula into cell A1 of the active sheet (change to suit):

Code:
Option Explicit
Sub Macro1()

    Range("A1").Formula = "=IF(ISNA(VLOOKUP(A2,'Original BHHS List'!$A$1:$A$84,1,FALSE)), ""Not Duplicate"", ""Duplicate"")"

End Sub

Regards,

Robert
 
Upvote 0

PaulCL

New Member
Joined
Jul 9, 2014
Messages
43
ADVERTISEMENT
Range("B2").Formula = "=IF(ISNA(VLOOKUP(A2,'Original BHHS Error List'!$A$1:$A$84,1,FALSE)), ""New Error"", ""Duplicate Error"")"

What would be the code to have the result of the formula in "B2" filldown as far as there is data in column A
Tks
 
Upvote 0

Trebor76

Well-known Member
Joined
Jul 23, 2007
Messages
5,129
Try this:

Code:
Range("B2:B" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=IF(ISNA(VLOOKUP(A2,'Original BHHS Error List'!$A$1:$A$84,1,FALSE)), ""New Error"", ""Duplicate Error"")"

Robert
 
Upvote 0

Forum statistics

Threads
1,195,704
Messages
6,011,206
Members
441,594
Latest member
AVO

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
Top