Cập nhật nội dung chi tiết về **How To Use The Excel Vlookup Function** mới nhất trên website Beiqthatgioi.com. Hy vọng thông tin trong bài viết sẽ đáp ứng được nhu cầu ngoài mong đợi của bạn, chúng tôi sẽ làm việc thường xuyên để cập nhật nội dung mới nhằm giúp bạn nhận được thông tin nhanh chóng và chính xác nhất.

VLOOKUP is an Excel function to get data from a table organized vertically. Lookup values must appear in the first column of the table passed into VLOOKUP. VLOOKUP supports approximate and exact matching, and wildcards (* ?) for partial matches.

V is for vertical

The purpose of VLOOKUP is to get information from a table organized like this:

Using the Order number in column B as a lookup value, VLOOKUP can get the Customer ID, Amount, Name, and State for any order. For example, to get the customer name for order 1004, the formula is:

=

VLOOKUP

(

1004

,

B5:F9,

4

,

FALSE

)

// returns "Sue Martin"

For horizontal data, you can use the HLOOKUP, INDEX and MATCH, or XLOOKUP.

VLOOKUP is based on column numbers

When you use VLOOKUP, imagine that every column in the table is numbered, starting from the left. To get a value from a particular column, provide the appropriate number as the “column index”. For example, the column index to retrieve the first name below is 2:

The last name and email can be retrieved with columns 3 and 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 only looks right

VLOOKUP can only look to the right. The data you want to retrieve (result values) can appear in any column to the right of the lookup values:

If you need to lookup values to the left, see INDEX and MATCH, or XLOOKUP.

Exact and approximate matching

VLOOKUP has two modes of matching, exact and approximate. The name of the argument that controls matching is “range_lookup“. This is a confusing name, because it seems to have something to do with cell ranges like A1:A10. Actually, the word “range” in this case refers to “range of values” – when range_lookup is TRUE, VLOOKUP will match a range of values rather than an exact value. A good example of this is using VLOOKUP to calculate grades.

It is important to understand that range_lookup defaults to TRUE, which means VLOOKUP will use approximate matching by default, which can be dangerous. Set range_lookup to FALSE to force exact matching:

=

VLOOKUP

(

value,

table,

col_index)

// approximate match (default)

=

VLOOKUP

(

value,

table,

col_index,

TRUE

)

// approximate match

=

VLOOKUP

(

value,

table,

col_index,

FALSE

)

// exact match

Note: You can also supply zero (0) instead of FALSE for an exact match.

Exact match

In most cases, you’ll probably want to use VLOOKUP in exact match mode. This makes sense when you have a unique key to use as a lookup value, for example, the movie title in this data:

The formula in H6 to find Year, based on an exact match of movie title, is:

=

VLOOKUP

(

H4,

B5:E9,

2

,

FALSE

)

// FALSE = exact match

Approximate 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

=

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 the 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 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

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.

## How To Use The Excel Countifs Function

The COUNTIFS function in Excel counts the number of cells in a range that match one supplied criteria. Unlike the older COUNTIF function, COUNTIFS can apply more more than one condition at the same time. Conditions are supplied with range/criteria pairs, and only the first pair is required. For each additional condition, you must supply another range/criteria pair. Up to 127 range/criteria pairs are allowed.

COUNTIFS is in a group of eight functions in Excel that split logical criteria into two parts (range + criteria). As a result, the syntax used to construct criteria is different, and COUNTIFS requires a cell range for range arguments, you can’t use an array.

Basic example

With the example shown, COUNTIFS can be used to count records using 2 criteria as follows:

=

COUNTIFS

(

C5:C14,

"red"

,

D5:D14,

"tx"

)

// red and TX

Notice the COUNTIFS function is not case-sensitive.

Double quotes ("") in criteria

In general, text values need to be enclosed in double quotes, and numbers do not. However, when a logical operator is included with a number, the number and operator must be enclosed in quotes as shown below:

=

COUNTIFS

(

A1:A10,

100

)

// count equal to 100

=

COUNTIFS

(

A1:A10,

"jim"

)

// count equal to "jim"

Note: showing one condition only for simplicity. Additional conditions must follow the same rules.

Value from another cell

When using a value from another cell in a condition, the cell reference must be concatenated to an operator when used. In the example below, COUNTIFS will count the values in A1:A10 that are less than the value in cell B1. Notice the less than operator (which is text) is enclosed in quotes, but the cell reference is not:

=

COUNTIFS

(

A1:A10,

"<"

&

B1)

// count cells less than B1

Note: COUNTIFS is one of several functions that split conditions into two parts: range + criteria. This causes some inconsistencies with respect to other formulas and functions.

Not equal to

To construct "not equal to" criteria, use the "" operator surrounded by double quotes (""). For example, the formula below will count cells not equal to "red" in the range A1:A10:

Blank cells

COUNTIFS can count cells that are blank or not blank. The formulas below count blank and not blank cells in the range A1:A10:

=

COUNTIFS

(

A1:A10,

""

)

// blank

Dates

The easiest way to use COUNTIFS with dates is to refer to a valid date in another cell with a cell reference. For example, to count cells in A1:A10 that contain a date greater than a date in B1, you can use a formula like this:

The safest way hardcode a date into COUNTIFS is with the DATE function. This guarantees Excel will understand the date. To count cells in A1:A10 that contain a date less than September 1, 2020, you can use:

=

COUNTIFS

(

A1:A10,

"<"

&

DATE

(

2020

,

9

,

1

))

// dates less than 1-Sep-2020

Wildcards

The wildcard characters question mark (?), asterisk(*), or tilde (~) can be used in criteria. A question mark (?) matches any one character, and an asterisk (*) matches zero or more characters of any kind. For example, to count cells in a A1:A5 that contain the text "apple" anywhere, you can use a formula like this:

=

COUNTIFS

(

A1:A5,

"*apple*"

)

// count cells that contain "apple"

The tilde (~) is an escape character to allow you to find literal wildcards. For example, to count a literal question mark (?), asterisk(*), or tilde (~), add a tilde in front of the wildcard (i.e. ~?, ~*, ~~).

Notes

Multiple conditions are applied with AND logic, i.e. condition 1 AND condition 2, etc.

Each additional range must have the same number of rows and columns as range1, but ranges do not need to be adjacent. If you supply ranges that don't match, you'll get a #VALUE error.

The wildcard characters ? and * can be used in criteria. A question mark matches any one character and an asterisk matches any sequence of characters.

To find a literal question mark or asterisk, use a tilde (~) in front question mark or asterisk (i.e. ~?, ~*).

## How To Use The Excel Sumif Function

SUMIF is in a group of eight functions in Excel that split logical criteria into two parts (range + criteria). As a result, the syntax used to construct criteria is different, and SUMIF requires a cell range for the range argument, you can’t use an array.

SUMIF only supports a single condition. If you need to apply multiple criteria, use the SUMIFS function. If you need to manipulate values that appear in the range argument (i.e. extract the year from dates to use in criteria) see the SUMPRODUCT and/or FILTER functions.

Videos

Basic usage

In the worksheet shown, there are three SUMIF examples. In the first example (G6), SUMIF is configured to sum values greater than 100. In the second example (G7), SUMIF returns the sum of values where the color is “red”. In the last example (G8), SUMIF is configured to sum values where the state is “CA” (California).

=

SUMIF

(

B6:B10,

"Jim"

,

D6:D10)

// Rep = Jim

=

SUMIF

(

C6:C10,

"ca"

,

D6:D10)

// State = CA

Notice the equals sign (=) is not required when constructing “is equal to” criteria. Also notice SUMIF is not case-sensitive. You can sum values where the Rep is Jim using “jim” or “Jim”.

Criteria in another cell

Not equal to

To express "not equal to" criteria, use the "" operator surrounded by double quotes (""):

Again notice SUMIF is not case-sensitive.

Blank cells

SUMIF can calculate sums based on cells that are blank or not blank. In the example below, SUMIF is used to sum the amounts in column C depending on whether column D contains "x" or is empty:

=

SUMIF

(

D5:D9,

""

,

C5:C9)

// blank

The best way to use SUMIF with dates is to refer to a valid date in another cell, or use the DATE function. The example below shows both methods:

=

SUMIF

(

B5:B9,

"<"

&

DATE

(

2019

,

3

,

1

),

C5:C9)

Wildcards

The SUMIF function supports wildcards, as seen in the example below:

=

SUMIF

(

B5:B9,

"mi*"

,

C5:C9)

// begins with "mi"

=

SUMIF

(

B5:B9,

"*ota"

,

C5:C9)

// ends with "ota"

=

SUMIF

(

B5:B9,

"????"

,

C5:C9)

// contains 4 characters

See below for more SUMIF formula examples.

Notes

SUMIF only supports one condition. Use the SUMIFS function for multiple criteria.

When sum_range is omitted, the cells in range will be summed.

Cell references in criteria are not enclosed in quotes, i.e. "

The wildcard characters ? and * can be used in criteria. A question mark matches any one character and an asterisk matches any sequence of characters (zero or more).

To find a literal question mark or asterisk, use a tilde (~) in front question mark or asterisk (i.e. ~?, ~*).

SUMIFS requires a range, you can't substitute an array.

## How To Use The Excel Subtotal Function

Use the SUBTOTAL function to get a subtotal in a list or database. Despite the name, SUBTOTAL has the ability to perform a variety of math functions, including AVERAGE, COUNT, MAX, and many others (see table below for the complete list). SUBTOTAL returns an aggregate result from a set of data. By default, SUBTOTAL excludes values in rows hidden by a filter, which makes SUBTOTAL very useful in Excel Tables.

The SUBTOTAL function automatically ignores other SUBTOTAL formulas that exist in references to prevent double-counting.

Examples

Below are a few examples of SUBTOTAL configured to SUM, COUNT, and AVERAGE the values in a range. Notice the only difference is the value used for the function_num argument:

=

SUBTOTAL

(

109

,

range)

// SUM

=

SUBTOTAL

(

103

,

range)

// COUNT

=

SUBTOTAL

(

101

,

range)

// AVERAGE

Available calculations

SUBTOTAL behavior is controlled by the function_num argument, which is provided as a numeric value. There are 11 functions available, each with two options, as seen in the table below. Notice the values are “paired” (e.g. 1-101, 2-102, 3-103, and so on). This is related to how SUBTOTAL deals with manually hidden rows. When function_num is between 1-11, SUBTOTAL includes cells that have been manually hidden. When function_num is between 101-111, SUBTOTAL excludes values in rows that have been manually hidden.

Function Include hidden Ignore hidden

AVERAGE 1 101

COUNT 2 102

COUNTA 3 103

MAX 4 104

MIN 5 105

PRODUCT 6 106

STDEV 7 107

STDEVP 8 108

SUM 9 109

VAR 10 110

VARP 11 111

Note: SUBTOTAL always ignores values in cells that are hidden with a filter. Values in rows that have been “filtered out” are never included, regardless of function_num.

SUBTOTAL in Excel Tables

The SUBTOTAL function is used when you display a Total row in an Excel Table. Excel inserts the SUBTOTAL function automatically, and you can use a drop-down menu to switch behavior and show max, min, average, etc. The reason Excel uses SUBTOTAL for calculations in the Total row of an Excel Table is because SUBTOTAL automatically excludes rows hidden by the filter controls at the top of the table. That is, as you filter rows in a table with a Total row, you’ll see the calculations update automatically to respect the filter.

SUBTOTAL with outlines

Note: although the Outline feature is an “easy” way to insert subtotals in a set of data, a Pivot Table is a better and more flexible way to analyze data. In addition, a Pivot Table will separate the data from the presentation of the data, which is a best practice.

Notes

When function_num is between 1-11, SUBTOTAL includes values that are hidden

When function_num is between 101-111, SUBTOTAL excludes values that are hidden

In filtered lists, SUBTOTAL always ignores values in hidden rows, regardless of function_num.

SUBTOTAL ignores other SUBTOTAL formulas that exist in references to prevent double-counting.

SUBTOTAL is designed to work with vertical data values arranged vertically. In horizontal ranges, values in hidden columns are always included.

Bạn đang đọc nội dung bài viết **How To Use The Excel Vlookup Function** trên website Beiqthatgioi.com. Hy vọng một phần nào đó những thông tin mà chúng tôi đã cung cấp là rất hữu ích với bạn. Nếu nội dung bài viết hay, ý nghĩa bạn hãy chia sẻ với bạn bè của mình và luôn theo dõi, ủng hộ chúng tôi để cập nhật những thông tin mới nhất. Chúc bạn một ngày tốt lành!