I have a problem with using Xlookup in a macro. VBA gives this error:
Run-time error '424':
Object required
Here is the relevant VBA code:
FullName = ActiveSheet.Range("$C$14").Value
FindName = WorksheetFunction.XLookup(FullName, tblPhones![Full], tblPhones![Phone], "New Name")
I am at a loss trying to figure this out. The XLookup as a formula directly in the worksheet as a test and replacing FullName with the cell address works just fine with the ! removed in the table references, but in the macro I get a different error if I don't include the !. I am running Excel 365.
You can't refer to table ranges like that. You need to use something like:
FindName = WorksheetFunction.XLookup(FullName, Application.Range("tblPhones[Full]"), Application.Range("tblPhones[Phone]"), "New Name")
Thanks Velouria! That fixed it.