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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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
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
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,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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