Excel 2016: Excel VBA - Convert Worksheet Formula into VBA Code

ajay_gajree

Well-known Member
Joined
Jul 16, 2011
Messages
518
Hi all, How do I convert the below into VBA code?

HTML:
=IF(AB2=IFERROR(VLOOKUP(AB2,tblBRPDatabase[Primay Key],1,FALSE),"No Existing Record in the Database"),"Record Already Exists","No Existing Record in the Database")

I have tried the below and it isn't working?

Code:
On Error Resume Next
    x = Application.VLookup(TextBox1.Value, Worksheets("BRP Database").ListObjects("tblBRPDatabase"), 2, False)
    If x = "" Then
    Me.TextBox2.Value = "No Existing Record in the Database"
    Else
    Me.TextBox2.Value = "Record Already Exists"
    End If

Any help appreciated!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,214,942
Messages
6,122,367
Members
449,080
Latest member
Armadillos

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