---
schema_version: "1"
id: 30d0ec65b03341ff396c467130a5a225b156f4f1167803ad72f178f589856d8d
title: VLOOKUP
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/customize_functions_vlookup.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.customize_functions_vlookup.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 3ca83dbad1e22e102ce132f7310d130b49e8092308c20e26e5d9cb6f277d7d61
description: Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function. This function is only available in validation rules.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# VLOOKUP

Returns a value by looking up a related value on a custom object similar to the VLOOKUP() Excel function. This function is only available in validation rules.

## Use

VLOOKUP (field\_to\_return, field\_on\_lookup\_object, lookup\_value). Replace field\_to\_return with the field that contains the value you want returned, field\_on\_lookup\_object with the field on the related object that contains the value you want to match, and lookup\_value with the value you want to match.

## Tips

- field\_to\_return must be an auto number, roll up summary, lookup relationship, master-detail relationship, checkbox, date, date/time, email, number, percent, phone, text, text area, or URL field type.
- field\_on\_lookup\_object must be the Record Name field on a custom object.
- field\_on\_lookup\_object and lookup\_value must be the same data type.
- If more than one record matches, the value from the first record is returned.
- The value returned must be on a custom object.
- You can’t delete the custom field or custom object referenced in this function.

![Validation Rule Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_example.png)

Validation Rule Example

This example checks that a billing postal code is valid by looking up the first five characters of the value in a custom object called Zip\_Code\_\_c that contains a record for every valid ZIP code in the US. If the ZIP code isn’t found in the Zip\_Code\_\_c object or the billing state doesn’t match the corresponding State\_Code\_\_c in the Zip\_Code\_\_c object, an error displays.

```
AND(
    LEN(BillingPostalCode) > 0, 
    OR(BillingCountry = "USA", BillingCountry = "US"), 
    VLOOKUP(
        $ObjectType.Zip_Code__c.Fields.State_Code__c,
        $ObjectType.Zip_Code__c.Fields.Name,
        LEFT(BillingPostalCode,5)
    ) <> BillingState
)
```

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_note.png)

Note

- Use this example when the billing country is US or USA.
- You can download US ZIP codes in CSV file format from [http://zips.sourceforge.net](http://zips.sourceforge.net).

#### See Also

- [Validation Rules](https://help.salesforce.com/s/articleView?id=platform.fields_about_field_validation.htm&release=264.0.0&type=5 "Improve the quality of your data using validation rules. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record.")