
Περίληψη
Το VLOOKUP είναι μια συνάρτηση του Excel για την αναζήτηση δεδομένων σε έναν πίνακα οργανωμένο κάθετα. Το VLOOKUP υποστηρίζει κατά προσέγγιση και ακριβή αντιστοίχιση και μπαλαντέρ (*?) Για μερικούς αγώνες. Οι τιμές αναζήτησης πρέπει να εμφανίζονται στην πρώτη στήλη του πίνακα που έχει περάσει στο VLOOKUP.
Σκοπός
Αναζητήστε μια τιμή σε έναν πίνακα αντιστοιχίζοντας στην πρώτη στήληΤιμή επιστροφής
Η αντιστοιχισμένη τιμή από έναν πίνακα.Σύνταξη
= VLOOKUP (τιμή, πίνακας, col_index, (range_lookup))Επιχειρήματα
- τιμή - Η τιμή που πρέπει να αναζητήσετε στην πρώτη στήλη ενός πίνακα.
- table - Ο πίνακας από τον οποίο μπορείτε να ανακτήσετε μια τιμή.
- col_index - Η στήλη στον πίνακα από την οποία μπορείτε να ανακτήσετε μια τιμή.
- range_lookup - (προαιρετικό) TRUE = κατά προσέγγιση αντιστοίχιση (προεπιλογή). FALSE = ακριβής αντιστοίχιση.
Εκδοχή
Excel 2003Σημειώσεις χρήσης
Το VLOOKUP είναι μια συνάρτηση Excel για τη λήψη δεδομένων από έναν πίνακα οργανωμένο κάθετα. Οι τιμές αναζήτησης πρέπει να εμφανίζονται στην πρώτη στήλη του πίνακα που έχει περάσει στο VLOOKUP. Το VLOOKUP υποστηρίζει κατά προσέγγιση και ακριβή αντιστοίχιση, και μπαλαντέρ (*?) Για μερικούς αγώνες.
Κάθετα δεδομένα | Αριθμοί στηλών | Μόνο φαίνεται σωστό | Λειτουργίες αντιστοίχισης | Ακριβής αντιστοίχιση | Κατά προσέγγιση αντιστοίχιση | Πρώτος αγώνας | Αγώνας μπαλαντέρ | Αμφίδρομη αναζήτηση | Πολλαπλά κριτήρια | # N / A Σφάλματα | Βίντεο
Το V είναι για κάθετο
Ο σκοπός του VLOOKUP είναι να λάβετε πληροφορίες από έναν πίνακα οργανωμένο ως εξής:
Χρησιμοποιώντας τον αριθμό παραγγελίας στη στήλη B ως τιμή αναζήτησης, το VLOOKUP μπορεί να λάβει το αναγνωριστικό πελάτη, το ποσό, το όνομα και την κατάσταση για οποιαδήποτε παραγγελία. Για παράδειγμα, για να λάβετε το όνομα πελάτη για την παραγγελία 1004, ο τύπος είναι:
=VLOOKUP(1004,B5:F9,4,FALSE) // returns "Sue Martin"
Για οριζόντια δεδομένα, μπορείτε να χρησιμοποιήσετε τα HLOOKUP, INDEX και MATCH ή XLOOKUP.
Το VLOOKUP βασίζεται σε αριθμούς στηλών
Όταν χρησιμοποιείτε το VLOOKUP, φανταστείτε ότι κάθε στήλη στον πίνακα είναι αριθμημένη, ξεκινώντας από τα αριστερά. Για να λάβετε μια τιμή από μια συγκεκριμένη στήλη, δώστε τον κατάλληλο αριθμό ως "ευρετήριο στηλών". Για παράδειγμα, το ευρετήριο στηλών για ανάκτηση του πρώτου ονόματος παρακάτω είναι 2:
Το επώνυμο και το email μπορούν να ανακτηθούν με τις στήλες 3 και 4:
=VLOOKUP(H3,B4:E13,2,FALSE) // first name =VLOOKUP(H3,B4:E13,3,FALSE) // last name =VLOOKUP(H3,B4:E13,4,FALSE) // email address
Το VLOOKUP φαίνεται μόνο σωστό
Το VLOOKUP μπορεί να κοιτάξει μόνο προς τα δεξιά. Τα δεδομένα που θέλετε να ανακτήσετε (τιμές αποτελεσμάτων) μπορούν να εμφανιστούν σε οποιαδήποτε στήλη στα δεξιά των τιμών αναζήτησης:
Εάν πρέπει να αναζητήσετε τιμές προς τα αριστερά, δείτε INDEX και MATCH ή XLOOKUP.
Ακριβής και κατά προσέγγιση αντιστοίχιση
Το VLOOKUP έχει δύο τρόπους αντιστοίχισης, ακριβείς και κατά προσέγγιση. Το όνομα του ορίσματος που ελέγχει την αντιστοίχιση είναι " range_lookup ". Αυτό είναι ένα μπερδεμένο όνομα, γιατί φαίνεται να έχει σχέση με τις περιοχές κυψελών όπως το A1: A10. Στην πραγματικότητα, η λέξη "εύρος" σε αυτήν την περίπτωση αναφέρεται σε "εύρος τιμών" - όταν το εύρος_επισκόπησης είναι ΑΛΗΘΟΣ, το VLOOKUP θα ταιριάζει με ένα εύρος τιμών αντί για μια ακριβή τιμή. Ένα καλό παράδειγμα αυτού είναι η χρήση του VLOOKUP για τον υπολογισμό των βαθμών.
Είναι σημαντικό να καταλάβετε ότι το range_lookup είναι προεπιλεγμένο στο TRUE, πράγμα που σημαίνει ότι το VLOOKUP θα χρησιμοποιεί κατά προσέγγιση αντιστοίχιση από προεπιλογή, κάτι που μπορεί να είναι επικίνδυνο. Ορίστε range_lookup σε FALSE για να επιβάλλετε την ακριβή αντιστοίχιση
=VLOOKUP(value, table, col_index) // approximate match (default) =VLOOKUP(value, table, col_index, TRUE) // approximate match =VLOOKUP(value, table, col_index, FALSE) // exact match
Σημείωση: Μπορείτε επίσης να παρέχετε μηδέν (0) αντί για FALSE για έναν ακριβή αγώνα.
Ακριβής αντιστοίχιση
Στις περισσότερες περιπτώσεις, ίσως θέλετε να χρησιμοποιήσετε το VLOOKUP σε λειτουργία ακριβούς αντιστοίχισης. Αυτό έχει νόημα όταν έχετε ένα μοναδικό κλειδί για χρήση ως τιμή αναζήτησης, για παράδειγμα, ο τίτλος της ταινίας σε αυτά τα δεδομένα:
Ο τύπος στο H6 για να βρείτε το Έτος , με βάση τον ακριβή αγώνα του τίτλου της ταινίας, είναι:
=VLOOKUP(H4,B5:E9,2,FALSE) // FALSE = exact match
Κατά προσέγγιση αντιστοίχιση
In cases when you want the best match , not necessarily an exact match , you'll want to use approximate mode. For example, below we want to look up a commission rate in the table G5:H10. The lookup values come from column C. In this example, we need to use VLOOKUP in approximate match mode, because in most cases an exact match will never be found. The VLOOKUP formula in D5 is configured to perform an approximate match by setting the last argument to TRUE:
=VLOOKUP(C5,$G$5:$H$10,2,TRUE) // TRUE = approximate match
VLOOKUP will scan values in column G for the lookup value. If an exact match is found, VLOOKUP will use it. If not, VLOOKUP will "step back" and match the previous row.
Note: data must be sorted in ascending order by lookup value when you use approximate match mode with VLOOKUP.
First match
In the case of duplicate values, VLOOKUP will find the first match when the match mode is exact. In screen below, VLOOKUP is configured to find the price for the color "Green". There are three entries with the color Green, and VLOOKUP returns the price for the first entry, $17. The formula in cell F5 is:
=VLOOKUP(E5,B5:C11,2,FALSE) // returns 17
Wildcard match
The VLOOKUP function supports wildcards, which makes it possible to perform a partial match on a lookup value. For instance, you can use VLOOKUP to retrieve values from a table after typing in only part of a lookup value. To use wildcards with VLOOKUP, you must specify exact match mode by providing FALSE or 0 for the last argument, range_lookup . The formula in H7 retrieves the first name, "Michael", after typing "Aya" into cell H4:
=VLOOKUP($H$4&"*",$B$5:$E$104,2,FALSE)
Read a more detailed explanation here.
Two-way lookup
Inside the VLOOKUP function, the column index argument is normally hard-coded as a static number. However, you can also create a dynamic column index by using the MATCH function to locate the right column. This technique allows you to create a dynamic two-way lookup, matching on both rows and columns. In the screen below, VLOOKUP is configured to perform a lookup based on Name and Month. The formula in H6 is:
=VLOOKUP(H4,B5:E13,MATCH(H5,B4:E4,0),0)
For more details, see this example.
Note: In general, INDEX and MATCH is a more flexible way to perform two-way lookups.
Multiple criteria
The VLOOKUP function does not handle multiple criteria natively. However, you can use a helper column to join multiple fields together, and use these fields like multiple criteria inside VLOOKUP. In the example below, Column B is a helper column that concatenates first and last names together with this formula:
=C5&D5 // helper column
VLOOKUP is configured to do the the same thing to create a lookup value. The formula in H6 is:
=VLOOKUP(H4&H5,B5:E13,4,0)
For details, see this example.
Note: INDEX and MATCH and XLOOKUP are more robust ways to handle lookups based on multiple criteria.
VLOOKUP and #N/A errors
If you use VLOOKUP you will inevitably run into the #N/A error. The #N/A error just means "not found". For example, in the screen below, the lookup value "Toy Story 2" does not exist in the lookup table, and all three VLOOKUP formulas return #N/A:
One way to "trap" the NA error is to use the IFNA function like this:
The formula in H6 is:
=IFNA(VLOOKUP(H4,B5:E9,2,FALSE),"Not found")
The message can be customized as desired. To return nothing (i.e. to display a blank result) when VLOOKUP returns #N/A you can use an empty string like this:
=IFNA(VLOOKUP(H4,B5:E9,2,FALSE),"") // no message
The #N/A error is useful because it tells you something is wrong. In practice, there are many reasons why you might see this error, including:
- The lookup value does not exist in the table
- The lookup value is misspelled, or contains extra space
- Match mode is exact, but should be approximate
- The table range is not entered correctly
- You are copying VLOOKUP, and the table reference is not locked
Read more: VLOOKUP without #N/A errors
More about VLOOKUP
- More VLOOKUP examples
- VLOOKUP videos
- 23 tips for using VLOOKUP
Other notes
- Range_lookup controls whether value needs to match exactly or not. The default is TRUE = allow non-exact match.
- Set range_lookup to FALSE to require an exact match and TRUE to allow a non-exact match .
- If range_lookup is TRUE (the default setting), a non-exact match will cause the VLOOKUP function to match the nearest value in the table that is still less than value .
- When range_lookup is omitted, the VLOOKUP function will allow a non-exact match, but it will use an exact match if one exists.
- If range_lookup is TRUE (the default setting) make sure that lookup values in the first row of the table are sorted in ascending order. Otherwise, VLOOKUP may return an incorrect or unexpected value.
- If range_lookup is FALSE (require exact match), values in the first column of table do not need to be sorted.
Related videos





