Excel Formula – ExcelCSE.com https://excelcse.com The Ultimate Guide How to Use Excel Better Thu, 25 Apr 2019 06:25:30 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.10 Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel https://excelcse.com/number-of-days-weeks-months-and-years-between-two-dates/ Thu, 25 Apr 2019 06:25:30 +0000 https://excelcse.com/?p=1345 Calculate Number of Days Between Two Dates Excel has a function that calculates the number of days between two dates, the DATEDIF function. The Formula =DATEDIF(A2,B2,"d") You got the number of days between two dates, but there is one problem, cell C4 returns an error. Error #NUM! happens because the end date is earlier than the start date. To fix the #NUM! Error, the solution is to use the subtraction formula. Excel stores date values as an integer number, to find out the number of days between two dates use the subtraction formula. The Formula =B2-A2 Look at cell C4,

The post Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel appeared first on ExcelCSE.com.

]]>
Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel

Calculate Number of Days, Weeks, Months and Years between Two Dates

Calculate Number of Days Between Two Dates

Excel has a function that calculates the number of days between two dates, the DATEDIF function.

Number of Days between Two Dates

The Formula

=DATEDIF(A2,B2,"d")

You got the number of days between two dates, but there is one problem, cell C4 returns an error. Error #NUM! happens because the end date is earlier than the start date.

Please read the article below for a more detailed explanation for DATEDIF function

To fix the #NUM! Error, the solution is to use the subtraction formula. Excel stores date values as an integer number, to find out the number of days between two dates use the subtraction formula.

Number of Days between Two Dates

The Formula

=B2-A2

Look at cell C4, the DATEDIF function returns a #NUM error, but with subtraction formula, there is no error but a negative number.

Calculate Number of Weeks Between Two Dates

To calculate the number of weeks between two dates divide the number of days between two dates by number 7. The result is the number of weeks between two dates.

Number of Weeks between Two Dates

The Formula

=(B2-A2)/7

A result is a decimal number, a number of weeks between October 29, 2018, and January 5, 2019, is 9.714286.

Is it possible to get a full week difference and shows the remaining days (that are not up to 1 week)? Of course, Excel can do this, thanks to the QUOTIENT and MOD function.

Number of Weeks between Two Dates

The Formula for weeks column

=QUOTIENT(B2-A2,7)

The Formula for days column

=MOD(B2-A2,7)

Between October 29, 2018, and January 5, 2019, there are nine weeks and five days.

Please read the article below for a more detailed explanation for QUOTIENT and MOD function

Calculate Number of Months Between Two Dates

To calculate the number of months between two dates, you must use the DATEDIF function. You cannot use the division formula that divides the number of days between two dates by 30. Why? Because in a month could be 28, 29, 30 or 31 days.

Number of Months between Two Dates

The Formula

=DATEDIF(A2,B2,"m")

You got a #NUM! error, it means the DATEDIF function unable to do a calculation if the end date is earlier than the start date.

The solution is to change the start date and the end date position if the end date is earlier than the start date. You need the IF function to do this trick.

Number of Months between Two Dates

The Formula

=IF(B2<A2,-1*DATEDIF(B2,A2,"m"),DATEDIF(A2,B2,"m"))

No more #NUM errors and cell C4 can display a negative number :).

The DATEDIF function result is a complete difference. If there is less than 1-month days difference, excel will ignore it.

How to calculate the remaining days that are not up to 1 month? still using the DATEDIF function but the unit argument is “md” (calculating the day difference by ignoring the difference in months).

Number of Months between Two Dates

The formula for days column

=IF(B2<A2,-1*DATEDIF(B2,A2,"md"),DATEDIF(A2,B2,"md"))

Calculate Number of Years Between Two Dates

How to calculate number of years, months and days between two dates?

Number of Years between Two Dates

The Formula for years column

=IF(B2<A2,-1*DATEDIF(B2,A2,"y"),DATEDIF(A2,B2,"y"))

The Formula for months column

=IF(B2<A2,-1*DATEDIF(B2,A2,"ym"),DATEDIF(A2,B2,"ym"))

The Formula for days column

=IF(B2<A2,-1*DATEDIF(B2,A2,"md"),DATEDIF(A2,B2,"md"))

Related Function

Usefull links
  • Microsoft Excel Calculate the Different between Two Dates documentation

The post Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel appeared first on ExcelCSE.com.

]]>
Add and Remove Leading Zeros in Excel https://excelcse.com/add-remove-leading-zeros-excel/ Thu, 21 Feb 2019 01:00:40 +0000 https://excelcse.com/?p=1165 Add Leading Zeros in Excel Add Leading Zeros for Numeric Values How to add leading zeros to numbers in column A? Solution #1, using the Format Cells menu Make a range selection A1:A7. Press CTRL+1 (Format Cells shortcut). Select Custom on the Number tab. Type a 7-digit zero number in the Fill type section, then click the OK button. All numbers with less than seven digits have a leading zero. Pay attention to the red arrow at formula bar; there is no leading zeros, only number 1. Its means leading zero is only the appearance, the data is still a

The post Add and Remove Leading Zeros in Excel appeared first on ExcelCSE.com.

]]>
How to Add & Remove Leading Zeros in Excel

Add remove leading zeros in excel

Add Leading Zeros in Excel

Add Leading Zeros for Numeric Values

How to add leading zeros to numbers in column A?

Add leading zeros in excel

Solution #1, using the Format Cells menu

How to add leading zeros in excel

Make a range selection A1:A7. Press CTRL+1 (Format Cells shortcut). Select Custom on the Number tab. Type a 7-digit zero number in the Fill type section, then click the OK button.

Excel show leading zeros

All numbers with less than seven digits have a leading zero. Pay attention to the red arrow at formula bar; there is no leading zeros, only number 1. Its means leading zero is only the appearance, the data is still a number.

Solution #2, using TEXT function

The Formula

=TEXT(A1,"0000000")

The Result

How to add a leading zero in excel

The result is the same as solution #1, but all data in column B are text, not numbers.

The formula bar displays the excel formula, not the data, to display the data, do a Copy – Paste Special – Values for all data in column B.

How to show leading zeros in excel

There are leading zeros in front of the number

Add Leading Zeros for Non-numeric Values

Solution #3, using REPT and LEN function

How to add leading zeros to text?

The Formula

=REPT("0",7-LEN(A1))&A1

The Result

Excel leading zeros formula

The excel REPT function write a text in N times. To get the N value, use the LEN function and subtract 7 by the LEN function result. The result is leading zero for non-numeric values.

Which One is the Best Solution?

To add a leading zero and keep the original values as a number, Format cells is the only option.

To add leading zero and convert it to text, you have two option. The excel TEXT function produces a simpler formula but adding leading zero for numeric values only. The otherwise, The REPT and LEN function able to add leading zero for numeric or non-numeric values.

The choice is yours.

Remove Leading Zeros in Excel

Remove Leading Zeros from Numeric Values

Solution #4, using Format Cells menu

Solution #4 is the opposite step in solution #1. Change cell format from custom to general.

Make a range selection A1:A7. Press CTRL+1 (Format Cells shortcut). Select General on the Number tab, then press ENTER.

Add remove leading zeros in excel

No leading zeros for all numbers.

Solution #5, using a mathematical formula

You can use all mathematical formulas to remove leading zeros, in one condition do not change the original value.

Addition formula

=A2+0

Subtraction formula

=A2-0

Multiplication formula

=A2*1

Division formula

=A2/1

All formulas above return the same results and all text changes to numbers.

Remove leading zeros in excel

Remove Leading Zeros from Alphanumeric Values

Solution #6, using Convert menu

How to remove leading zeros in excel

All data changes to numbers.

Solution #7, using VALUE function

The Formula

=VALUE(A1)

The Result

Remove leading zeros

All leading zero disappears, and all data become numbers.

Solution #8, using TEXT function

The Formula

=TEXT(A1,"#")

The Result

Excel remove leading zeros from text

All leading zero disappears, but the data remains as text.

Remove Leading Zeros from Non-numeric Values

Solution #9, using Excel Formula

The Formula

=RIGHT(A1,LEN(A1)-FIND(LEFT(SUBSTITUTE(A1,"0",""),1),A1)+1)

The Result

How to remove leading zeros

How does the formula above work?

The formula above looking for the first character position after leading zero, then take the character afterward.

The trick to finding the first character after the leading zero is to eliminate all “0” (zero) characters using the SUBSTITUTE function.

The Formula (Step1)

=SUBSTITUTE(A1,"0","")

How do you remove leading zeros in excel

All “0” (zero) characters disappear. Next is the LEFT function task to find the first character after leading zero.

The Formula (Step2)

=LEFT(SUBSTITUTE(A1,"0",""),1)

How to remove a leading zero in excel

After getting the first character after leading zero, the next step is to find the position of the character in the original data using the FIND function.

The Formula (Step3)

=FIND(LEFT(SUBSTITUTE(A1,"0",""),1),A1)

Delete leading zeros

After obtaining the first character position, the next step is to take all the characters from the first character position to the last.

Which function to use? Can you use the RIGHT function or MID function? Using the RIGHT function or MID function both need the LEN function.

The Formula (Step4)

=RIGHT(A1,LEN(A1)-FIND(LEFT(SUBSTITUTE(A1,"0",""),1),A1)+1)

Eliminate leading zeros in excel

The Formula (Step4, another alternative)

=MID(A1,FIND(LEFT(SUBSTITUTE(A1,"0",""),1),A1),LEN(A1))

Add remove leading zeros in excel

Which One is the Best Solution?

To remove leading zero from a number, do the opposite step of adding leading zero. Use the Format Cells menu (solution #4).

There are two options to remove leading zero from alphanumeric data, convert it to numbers or keep it as a text. To convert to a number the easiest way is to use the Convert menu (solution #6). If you want to keep it as a text, use the TEXT function (solution #8).

The hardest way is to eliminate leading zero for non-numeric value. You must use an excel formula and involve many functions, but that is the only option you have (solution #9).

Related Function

Related Articles

Another articles related to this article
Usefull links
  • Microsoft Excel keeping leading zeros and large numbers documentation

The post Add and Remove Leading Zeros in Excel appeared first on ExcelCSE.com.

]]>
How to Combine and Separate First and Last Name in Excel https://excelcse.com/combine-separate-first-last-name-excel/ Fri, 15 Feb 2019 01:00:55 +0000 https://excelcse.com/?p=1135 How to Combine First and Last Name in Excel How to combine first and last names in excel into one column without losing data. Solution #1, Using Ampersand Sign The Formula =A2&" "&B2 The Result Ampersand sign is a formula solution, with no excel function. Solution #2, Using CONCATENATE Function The Formula =CONCATENATE(A2," ",B2) The Result Similar to solution #1, you must write all the cell addresses together with the separator but the formula using an Excel function. Solution #3, Using TEXTJOIN Function The Formula =TEXTJOIN(" ",TRUE,A2:B2) The Result a simpler formula, you only write the separator once, cell addresses

The post How to Combine and Separate First and Last Name in Excel appeared first on ExcelCSE.com.

]]>
How to Combine and Separate First and Last Name in Excel

Combine Separate First and Last Name in Excel

How to Combine First and Last Name in Excel

How to combine first and last names in excel into one column without losing data.

Combine first and last name in excel

Solution #1, Using Ampersand Sign

The Formula

=A2&" "&B2

The Result

How to combine first and last name in excel

Ampersand sign is a formula solution, with no excel function.

Solution #2, Using CONCATENATE Function

The Formula

=CONCATENATE(A2," ",B2)

The Result

Excel formula to combine first and last name

Similar to solution #1, you must write all the cell addresses together with the separator but the formula using an Excel function.

Solution #3, Using TEXTJOIN Function

The Formula

=TEXTJOIN(" ",TRUE,A2:B2)

The Result

How to combine last name and first name in excel

a simpler formula, you only write the separator once, cell addresses are combined in the form of a range address, no need to write the cell address one by one.

For all solutions using a formula, don’t forget to do a Copy – Paste Special – Values for all combined names.

For what?

  • You can delete the first, and last name columns and no error occurs
  • You can copy the combined name to another place without any problems

Read the following article for a detailed explanation of paste special

Solution #4, Using Flash Fill Menu

Flash Fill is no formula solution. Place the cursor in cell C2. Type first and last name for the first name.

Do the same for the second name, after you type two or three letters, Excel displays all combined first and last name for all names. Press the ENTER button.

Combine first and last name

Solution #5, Using NOTEPAD

Do a copy for all first and last name then paste in NOTEPAD. There is a space between the two with varying widths, that is a TAB character.

Replace the TAB character to space with the “Replace” menu. Copy the results and paste them again in Excel. You got the full name with no formula 🙂

How do i combine first and last names in excel

Which One is the Best Solution?

If you choose to use a formula, my choice is solution #3 using the TEXTJOIN function. Use the range address, and you get a combined first and last names.

For no formula solution, my choice is solution #4 Using the “Flash Fill” menu. If you can’t do it in your Excel version, do it using NOTEPAD, solution #5.

Which of the two is better? A formula solution or no formula solution? I chose to use the “Flash Fill” Menu, no formula solution. What about your choice?

How to Separate First and Last Name in Excel

The first case opposite. How to separate first and last name from the full name?

Separate first and last name in excel

Solution #6, Using Excel Formula

The formula for First Name column

=LEFT(A2,SEARCH(" ",A2)-1)

The Result

How to separate first and last name in excel

The SEARCH function is looking for the space position that separates the first and last name. The LEFT function takes characters from the first character until the space position, reduced by 1.

The formula for Last Name column

=RIGHT(A2,LEN(A2)-SEARCH(" ",A2))

The Result

Excel formula to separate first and last name

The RIGHT function takes n characters from the right, to find out the n value, use the LEN function to calculate the character length minus the space position.

Solution #7, Using Text to Column Menu

The Text to Column menu is in the “Data” tab, the “Data Tools” group. You can access it using a shortcut /, A, E.

Block range A2:A14. Type /, A, E in sequence. A dialog appears for the text to column

Separate first and last name in excel formula

Select delimited then click next.

Excel formula to separate first and last name with comma

Excel provides many separators, because of space separate first and last names, then select space and click next.

Formula to separate first and last name in excel

You can format the separated data according to the conditions. For first and last names all is text. Change them into text, do it one by one. Click Finish.

How do i separate first and last names in excel

The full name disappears, change to first and last name

Which One is the Best Solution?

The “Text to Column” menu is my choice, no more questions.

Regardless of the number of words, three words, four words or even more “Text to Column” can separate them easily. If you use the excel formula, it could be your nightmare.

Related Function

Related Articles

Another articles related to this article
Usefull links
  • Microsoft Excel Combine First and Last Name documentation

The post How to Combine and Separate First and Last Name in Excel appeared first on ExcelCSE.com.

]]>
How to Merge Cells in Excel without Losing Data https://excelcse.com/how-to-merge-cells-in-excel-without-losing-data/ Thu, 14 Feb 2019 01:00:59 +0000 https://excelcse.com/?p=1122 To merge two cells or more without losing data, you cannot use the “Merge Cells” command because Excel only keeps the data in the upper-left cell, you lose data in another cell. The solution is to use a formula or other solution that is easier and faster, with no formula losing no data. For more details, read the explanation below. Solution #1, Using TEXTJOIN Function The excel TEXTJOIN function is the best function provided by Excel to merge multiple cells without losing data. Regardless of the number of cells to be merged, TEXTJOIN function requires only the range address, no

The post How to Merge Cells in Excel without Losing Data appeared first on ExcelCSE.com.

]]>
How to Merge Cells in Excel without Losing Data

How to Merge Cells in Excel without Losing Data

To merge two cells or more without losing data, you cannot use the “Merge Cells” command because Excel only keeps the data in the upper-left cell, you lose data in another cell.

The solution is to use a formula or other solution that is easier and faster, with no formula losing no data. For more details, read the explanation below.

Solution #1, Using TEXTJOIN Function

The excel TEXTJOIN function is the best function provided by Excel to merge multiple cells without losing data. Regardless of the number of cells to be merged, TEXTJOIN function requires only the range address, no need to type all the cell addresses to be merged.

How to Merge Two Cells in Excel without Losing Data

The Formula

=TEXTJOIN(" ",TRUE,A2:C2)

The next step is to delete the “First Name”, “Middle Name” and “Last Name” columns.

Merge Cells without Losing Data

An error appeared, the full name data that was already available properly disappeared instead with #REF! Error. This error occurs because the “Full Name” column contains a formula. You must convert the formula to the text, do this by doing a Copy (CTRL+C) – Paste Special (CTRL+ALT+V) – Values.

Please see the video tutorial below, for step by step:

For solutions with other functions, please read the following article:

Solution #2, Using Flash Fill Menu

Flash Fill is no formula solution. Type 1 combined data with the desired format in the first row. Type the combined data again in the second row, after two or three letters; the combined data list appears for all rows.

If the displayed data is as desired, press the ENTER button. You merge cells in excel without a formula. Delete the “First Name”, “Middle Name” and “Last Name” columns, because they are made without a formula no #REF! error will appear.

Solution #3, Using NOTEPAD

Yes, you can use NOTEPAD to combine multiple columns into one column. Do a copy (CTRL+C) in range A2:14, the range containing first, middle and last name then paste (CTRL+V) in NOTEPAD.

There are blank spaces with random width between first, middle and last name. The blank space is a TAB character. Use the “Replace” menu to change the TAB character to space. To get the TAB character, do a copy in a blank space between first and middle name.

The results are copied back then paste in Excel.

How to Merge Cells without Losing Data

Which One is the Best Solution?

The TEXTJOIN function is a new function, available in Excel 2019 or Excel 365 Subscription. If you don’t have this function, and still want to use a formula, you can consider other functions.

For no formula solutions, you can choose to use “Flash Fill” or NOTEPAD. Choose the most comfortable solution for you.

Related Function

Function used in this article

Related Articles

Another articles related to this article
Usefull links
  • Microsoft Excel MERGE and UNMERGE cells documentation

The post How to Merge Cells in Excel without Losing Data appeared first on ExcelCSE.com.

]]>
How to Merge Cells in Excel https://excelcse.com/how-to-merge-cells-in-excel/ Mon, 11 Feb 2019 01:00:00 +0000 https://excelcse.com/?p=1097 There are several ways to merge cells in excel, using formula or using no formula, losing data or losing no data. Which solution is right for you, please read the article below. Solution #1, Using Ribbon Menu The Merge Cells menu is in the “Home” tab and “Alignment” group. There are several options to choose from. Merge & Center Merge the selected cells into a single combined cell and make a center alignment. Merge Across Merge the selected cells into a combined cell for the same row Merge Across is a Merge Cell for several rows in one command, there

The post How to Merge Cells in Excel appeared first on ExcelCSE.com.

]]>
How to Merge Cells in Excel

How to Merge Cells in Excel

There are several ways to merge cells in excel, using formula or using no formula, losing data or losing no data. Which solution is right for you, please read the article below.

Solution #1, Using Ribbon Menu

The Merge Cells menu is in the “Home” tab and “Alignment” group. There are several options to choose from.

How to Merge Cells in Excel

Merge & Center

Merge the selected cells into a single combined cell and make a center alignment.

Merge Columns in Excel

Merge Across

Merge the selected cells into a combined cell for the same row

How to Merge Two Columns in Excel

Merge Across is a Merge Cell for several rows in one command, there is no difference in results between Merge Across and Merge Cell if the selected cells consist of one row

Merge Cells

Merge selected cells into a single combined cell without alignment.

Merge and Center in Excel

Unmerge Cells

Unmerge Cells returns the merged cells into the original form.

How to Merge Two Cells in Excel

Unmerge Cells only returns the cell to its original form, not the data.

Merge Cells Limitation

Merge Cells only merge the cells, not the data. Excel only keeps the upper-left values and discard other values. No commands can restore the discarded data, including unmerge cells

Solution #2, Using Right Click Menu

You can merge cells with the right-click menu, then select Format cell, a dialog appears as shown below.

Merge Two Cells in Excel

Check the Merge Cells check box in the Text control section. The other setup is optional. You can make text alignment or text orientation settings, all in one dialog.

Merge Rows in Excel

If you only check the Merge cells checkbox, the results are like the Merge Cells option on the Ribbon menu.

Solution #3, Using Ampersand “&” Sign

Merge and Center the Selected Cells

The Formula

=A2&" "&B2&" "&C2

The formulas merge the data in several columns into one column without losing data. The formula merges the data, not the cells.

Keep in mind!!

The new column as a result of combining several columns containing a formula, if you copy the formula and paste elsewhere could give the different results.

To avoid the different result, make sure you do a Copy – Paste Special – Values for all data in the combined column.

Please read the article below for detailed information about Paste Special.

Solution #4, Using CONCATENATE Function

Merge Text in Excel

The Formula

=CONCATENATE(A2," ",B2," ",C2)

The Formula writing for the CONCATENATE function and the ampersand sign requires you to write all the columns to be merged, along with the separator.

If there are many columns to be merged will create a long formula. For a simpler solution, use the TEXTJOIN function.

Solution #5, Using TEXTJOIN Function

Merge 2 Columns in Excel

The Formula

=TEXTJOIN(" ",TRUE,A2:C2)

The TEXTJOIN function allows you to merge cells using a range, without having to write one by one of the cells to be merged. Also, you only write the separator once, unlike the CONCATENATE function you must write the separator repeatedly.

Solution #6, Using the Magic Way

Merge 2 Cells in Excel

No formula, losing no data

Which One is the Best?

Solution #1 and #2 only merge the cells, not the data inside. As a result, you will lose some data.

Solution #3 and #4 are using the formula, losing no data because the merged cell is done by putting it in a new column. The disadvantage, you must write all the column addresses to be merged one by one as well as the separator.

Solution #5 using a formula, you only write the column range address and the separator once. But my choice is solution #6, simple, no formula, losing no data and magic 😊.

What about your choice?

Related Function

Usefull links
  • Microsoft Excel MERGE and UNMERGE cells documentation

The post How to Merge Cells in Excel appeared first on ExcelCSE.com.

]]>
VLOOKUP Multiple Criteria – Solution for Numeric or Non-Numeric Result https://excelcse.com/vlookup-multiple-criteria-solution-for-numeric-or-non-numeric-result/ Sat, 12 Jan 2019 01:00:45 +0000 https://excelcse.com/?p=1027 The Solution for Numeric Result For example, there is data like the picture below, how much is the price of an Apple iPhone XS? What is the formula to find the price, there are two criteria, manufacture=”Apple” and Model=”iPhone XS”. Is it possible to use the VLOOKUP function or is there another solution? Solution #1, SUMIFS Function If the lookup result is a number then forget the VLOOKUP function, you can use mathematical functions and produce a simpler formula, one of them is the SUMIFS function. The Formula =SUMIFS(C2:C14,A2:A14,F3,B2:B14,F4) The Result The result is $1,340 Solution #2, SUMPRODUCT Function Another

The post VLOOKUP Multiple Criteria – Solution for Numeric or Non-Numeric Result appeared first on ExcelCSE.com.

]]>
This is box title

VLOOKUP Multiple Criteria

The Solution for Numeric Result

For example, there is data like the picture below, how much is the price of an Apple iPhone XS?

VLOOKUP Multiple Matches

What is the formula to find the price, there are two criteria, manufacture=”Apple” and Model=”iPhone XS”. Is it possible to use the VLOOKUP function or is there another solution?

Solution #1, SUMIFS Function

If the lookup result is a number then forget the VLOOKUP function, you can use mathematical functions and produce a simpler formula, one of them is the SUMIFS function.

The Formula

=SUMIFS(C2:C14,A2:A14,F3,B2:B14,F4)

The Result

Excel VLOOKUP Multiple Criteria

The result is $1,340

Solution #2, SUMPRODUCT Function

Another mathematical function that you can use to look up a number with multiple criteria is the SUMPRODUCT function.

The Formula

=SUMPRODUCT(C2:C14,--(A2:A14=F3),--(B2:B14=F4))

The Result

Excel Lookup Multiple Criteria

For additional reference, please read

Solution #3, SUM Function and Array Formula

The last solution is to use the SUM function, not the usual SUM function but the SUM function that processes an array formula.

Because it is an array formula, you can’t end the writing of the formula by pressing the ENTER button but by pressing the CTRL+SHIFT+ENTER button simultaneously.

The Formula

=SUM((C2:C14)*(A2:A14=F3)*(B2:B14=F4))

The Result

Lookup Multiple Criteria

For additional reference, please read

The Solution for Non-Numeric Result

For example, there is data like the picture below, where does Evelyn Thao live?

How to VLOOKUP with Multiple Criteria

Solution #A, VLOOKUP Function and Helper Column

The limitation of the VLOOKUP function is only lookup for one condition, that is lookup_value. If there are two or more criteria the easiest way is to concatenate all the criteria in the lookup_value.

The next step is to create the helper column that contains a merge of two columns in table_array. The helper column will be the first column of table_array, where the VLOOKUP function will look for lookup_value that has been merged from two criteria.

The Formula for Helper Column

=B2&C2

The Formula to Lookup the State

=VLOOKUP(G3&G4,A2:D10,4,FALSE)

The Result

VLOOKUP Using Multiple Criteria

Solution #B, VLOOKUP Function, CHOOSE Function, and Array Formula

The solution #B uses the helper column too. The difference is solution #A using a worksheet for the helper column location while solution #B using a formula for the helper column location.

The CHOOSE function will occupy the table_array argument of the VLOOKUP function; the role is to create a virtual helper column in the formula. The virtual helper column consists of two columns. The first column contains a combination of first name and last name. The second column contains the name of the state.

The Formula

=VLOOKUP(F3&F4,CHOOSE({1,2},A2:A10&B2:B10,C2:C10),2,FALSE)

Because it is an array formula, end the formula writing by pressing the CTRL+SHIFT+ENTER button simultaneously.

The Result

VLOOKUP Based on Multiple Criteria

No helper column in the worksheet but the VLOOKUP function can do vlookup with two criteria.

For additional reference, please read

Solution #C, INDEX Function, MATCH Function, and Array Formula

The solution #C is similar to solution #B, creating a virtual helper column in the formula. If the solution #B uses the CHOOSE function to form a virtual helper column. Solution #C uses the INDEX and MATCH functions where the MATCH function is assigned to create a virtual helper column.

The Formula

=INDEX(C2:C10,MATCH(F3&F4,A2:A10&B2:B10,0),1)

End the formula writing by pressing CTRL+SHIFT+ENTER simultaneously, because the formula above is an array formula

The Result

Excel Formula VLOOKUP Multiple Criteria

For additional reference, please read

Which One is the Best Solution?

For Numeric Result

The SUMIFS function is the best solution, simple and answers the questions. If the SUMIFS function is not available in your excel (seriously? you should upgrade your excel version 😊), then you can use the SUMPRODUCT function, or you can use SUMIF with multiple criteria.

For Non-Numeric Result

The easiest solution is to use the VLOOKUP function and the helper column. If you want no helper column in the worksheet, then you can use the virtual helper column in the formula.

There are two options, The VLOOKUP and CHOOSE function or INDEX and MATCH function, both is an array formula. Choose the most comfortable formula for you.

You can use all solutions for the non-numeric result to look up the numeric result with multiple criteria, but not otherwise. TRY IT AT HOME 😊

Practice File Download

Download File

 

Related Function

Usefull links
  • Using multiple criteria in Excel Lookup formulas

The post VLOOKUP Multiple Criteria – Solution for Numeric or Non-Numeric Result appeared first on ExcelCSE.com.

]]>
VLOOKUP MATCH – a Combination for a Solution https://excelcse.com/vlookup-match/ Thu, 10 Jan 2019 01:00:34 +0000 https://excelcse.com/?p=972 VLOOKUP MATCH – Solution for VLOOKUP REF Error The article “VLOOKUP REF Error – Causes and Solutions” explains the possibility of a REF error, or there is no REF error, but the resulting data is incorrect. The following article explains how to prevent these two problems. The First Case For example, there is data as shown below. How much is the total bill for all ordered drinks with the “Venti” size? The Formula =VLOOKUP(F4,$A$2:$D$13,4,FALSE) The price for the “Venti” size is in the fourth column of table_array, so the col_index_num argument is number 4 The Result What if you delete

The post VLOOKUP MATCH – a Combination for a Solution appeared first on ExcelCSE.com.

]]>
This is box title

VLOOKUP MATCH

VLOOKUP MATCH – Solution for VLOOKUP REF Error

The article “VLOOKUP REF Error – Causes and Solutions” explains the possibility of a REF error, or there is no REF error, but the resulting data is incorrect. The following article explains how to prevent these two problems.

The First Case

For example, there is data as shown below. How much is the total bill for all ordered drinks with the “Venti” size?

VLOOKUP MATCH

The Formula

=VLOOKUP(F4,$A$2:$D$13,4,FALSE)

The price for the “Venti” size is in the fourth column of table_array, so the col_index_num argument is number 4

The Result

VLOOKUP MATCH

What if you delete the column B (Tall Price)?

VLOOKUP MATCH

REF Error immediately appears in the column G. Is there any solution to prevent it, even though the column B “Tall Price” is removed the total bill for the “Venti” size could be known.

The solution is using VLOOKUP MATCH Formula.

The Modified Formula

=VLOOKUP(F4,$A$2:$D$13,MATCH("Venti",$A$1:$D$1,0),FALSE)

The MATCH function fills the col_index_num argument; the role is to find the “Venti” word position in range A1:D1.

What if you delete the column B (Tall Price)?

VLOOKUP MATCH

No REF error appears. Why? When the array dimension changes because of a delete operation, the MATCH function result changes too. When a “Tall Price” column exists the MATCH function returns 4, when you delete the “Tall Price” column the MATCH function returns 3.

The Second Case

For example, there is data like the picture below, the total bill for all “Tall” size drinks is $ 28.20.

VLOOKUP MATCH

What if you delete the column B (Tall Price)?

VLOOKUP MATCH

There is no error but the total bill changes to $33.35, it turns out the price of drinks changes from the “Venti” price size to the”Grande” price size. No error, but the formula result is wrong. It is a BIG problem.

How to prevent the wrong result? Of course, by displaying an error if the “Tall Price” column is deleted. The solution is using VLOOKUP MATCH Formula.

The Modified Formula

=VLOOKUP(F4,$A$2:$D$13,MATCH("Tall",$A$1:$D$1,0),FALSE)

The MATCH function occupies the col_index_num argument. The role is to find the “Tall” price column position.

If column B “Tall Price” is deleted the result as shown below.

VLOOKUP MATCH

NA error appears informing there is no price for the “Tall” size.

VLOOKUP MATCH – Solution for Dynamic col_index_num

For example, there is data as shown below. How do you calculate the total bill?

VLOOKUP MATCH

Unlike the previous case which only calculates the bills for one drink size. In the example above, the size of the ordered drink is different, so if you use the VLOOKUP function, the col_index_num argument could be numbers 2,3 or 4. If this is done manually one by one, it will be very time-consuming.

The solution is to use the MATCH function to find the drink price position according to their size.

The Formula

=VLOOKUP(F4,$A$2:$D$13,MATCH(G4,$A$1:$D$1,0),FALSE)

The Result

VLOOKUP MATCH

The other alternative for dynamic col_index_num is to use the INDEX MATCH MATCH formula, both return the same result.

Which one is your choice? The VLOOKUP MATCH Formula or the INDEX MATCH MATCH Formula?

Related Function

Usefull links
  • Look up values with VLOOKUP, INDEX, or MATCH

The post VLOOKUP MATCH – a Combination for a Solution appeared first on ExcelCSE.com.

]]>
IFERROR VLOOKUP – Solution for VLOOKUP NA Error https://excelcse.com/iferror-vlookup-solution-for-vlookup-na-error/ Tue, 25 Dec 2018 01:00:21 +0000 https://excelcse.com/?p=948 There is a condition, you have written the VLOOKUP function correctly but still returns an NA error, occurs when lookup_value does not exist in the first column of table_array. No problem, no lookup_value in the price table, but the total bill must show the bill for the ordered drink. The image below shows an NA error because there is no “Hot Brewed Coffee” in the price table. How is the solution to show the total bill for ordered drinks? Solution #1, Using IFERROR VLOOKUP Formula The solution is to add the IFERROR function in front of the VLOOKUP function. The

The post IFERROR VLOOKUP – Solution for VLOOKUP NA Error appeared first on ExcelCSE.com.

]]>
IFERROR VLOOKUP – Solution for VLOOKUP NA Error

IFERROR VLOOKUP

There is a condition, you have written the VLOOKUP function correctly but still returns an NA error, occurs when lookup_value does not exist in the first column of table_array. No problem, no lookup_value in the price table, but the total bill must show the bill for the ordered drink.

The image below shows an NA error because there is no “Hot Brewed Coffee” in the price table. How is the solution to show the total bill for ordered drinks?

Solution #1, Using IFERROR VLOOKUP Formula

The solution is to add the IFERROR function in front of the VLOOKUP function.

The Formula

=IFERROR(VLOOKUP(F4,$A$2:$D$13,2,FALSE),0)

Fill the value argument with the previous VLOOKUP function and value_if_false argument with zero number, meaning that if an error occurs then it will return zero number.

The Result

IFERROR VLOOKUP

The price for “Hot Brewed Coffee” becomes 0, and the total bill appears.

Solution #2, Using IFNA VLOOKUP Formula

The solution is to add the IFNA function in front of the VLOOKUP function. What is the difference between IFERROR and IFNA functions? The IFERROR function will catch all errors including the NA error, whereas IFNA only catches the NA error. So, you can use both functions to catch an NA error

The Formula

=IFNA(VLOOKUP(F4,$A$2:$D$13,2,FALSE),0)

The value argument is for the previous VLOOKUP function, and the value_if_false argument is for number 0.

The Result

IFNA VLOOKUP

The result is the same as solution # 1, the NA error disappears in cell H8, changes with the number 0 and the total bill displays all bills for the ordered drink.

Solution #3, Using IF ISNA VLOOKUP Formula

The solution #3 uses a combination of two functions, IF function and ISNA function. Use the ISNA function to detect whether a VLOOKUP function returns an NA error or not, while IF function is responsible for determining the result. If no NA error occurs, the result is from the VLOOKUP function, if an NA error occurs the result is the number 0.

The Formula

=IF(ISNA(VLOOKUP(F4,$A$2:$D$13,2,FALSE)),0,VLOOKUP(F4,$A$2:$D$13,2,FALSE))

The Result

IF ISNA VLOOKUP

The results remain the same as the two previous solutions.

Which One is the Best Solution

The IFERROR function and IFNA function are available in Excel 2013 or the newer version. If both functions are available in your excel version, please choose one. Solution #1 and solution #2 are the best solutions; both produce a more straightforward formula.

If the IFERROR function or IFNA function is not available, then solution #3 is the only choice you have. The formula is indeed longer because you must write the VLOOKUP function twice, but it solves the problem.

Another Alternative

The three solutions above all prevent NA errors to occurs to calculate the total bill. There is another solution by allowing NA errors to occurs, and excel can calculate the entire bill.

Please read the article below for a detailed explanation. a different case example, but you can solve the VLOOKUP NA error with the same function

Related Function

Usefull links
  • How to Correct NA Error in the VLOOKUP function

The post IFERROR VLOOKUP – Solution for VLOOKUP NA Error appeared first on ExcelCSE.com.

]]>
VLOOKUP Error – Frequently Error and Solution https://excelcse.com/vlookup-error/ Mon, 24 Dec 2018 01:00:22 +0000 https://excelcse.com/?p=914 The Wrong Cell Reference The wrong cell reference is the most common error when using the VLOOKUP function to look up for multiple data at once. For example, there is data like the picture below, how much you have to pay for all tall orders? To calculate the total bill the first step is to find the price of each drink. Place the cursor in cell H4 and use the VLOOKUP function to find the price of Caffe Mocha. =VLOOKUP(F4,A2:D13,2,FALSE) The result is $3.45 No need to write the formula one by one for each drink. Simply copy (CTRL+C) the

The post VLOOKUP Error – Frequently Error and Solution appeared first on ExcelCSE.com.

]]>
VLOOKUP - Frequently Error and Solution

VLOOKUP Error

The Wrong Cell Reference

The wrong cell reference is the most common error when using the VLOOKUP function to look up for multiple data at once. For example, there is data like the picture below, how much you have to pay for all tall orders?

VLOOKUP Error

To calculate the total bill the first step is to find the price of each drink. Place the cursor in cell H4 and use the VLOOKUP function to find the price of Caffe Mocha.

=VLOOKUP(F4,A2:D13,2,FALSE)

The result is $3.45

No need to write the formula one by one for each drink. Simply copy (CTRL+C) the formula in cell H4 then paste (CTRL+V) in range H5:H8. The result is as shown below.

VLOOKUP Error

Why does the #N/A error appear? Let’s check the formula for each drink one by one.

The formula for “Caffe Mocha” price, the lookup_value argument point to cell F4 (RIGHT) and table_array point to range A2:D13 (RIGHT).

The formula for “Caffe Latte” price, the lookup_value argument point to cell F5 (RIGHT) and table_array point to range A3:D14 (WRONG). Table_array shifts 1 row down when copied down, causing “Caffe Latte” in cell A2 outside the table_array range. The shifting table_array is what causes #N/A error.

The formula for “Toasted Graham Latte” price, the lookup_value argument point to cell F6 (RIGHT) and table_array POINT to the range A4:D15 (WRONG), but why is the price right?

The table_array range indeed shifts further and further from its starting point, but the “Toasted Graham Latte” price stays in the table_array range, so even the table_array shifts, as long as lookup_value stays in the table_array range, the VLOOKUP function still returns the correct result.

For the next two drinks price, the table_array range is getting far away from the starting point, but all lookup_value is still in table_array range.

The problem is in the table_array argument when the formula copied down the table_array range should keep pointing to range A2:D13.

The Solution

The solution is to use absolute cell reference to lock the table_array range.

VLOOKUP Error

“Caffe Latte” price known and all #N/A errors disappear.

For a more detailed explanation of what is relative cell reference, absolute cell reference and mixed cell reference read the following article:

VLOOKUP NA Error

There are five possibilities for VLOOKUP NA Error. Read the article below to find out the cause and solution for each error.

VLOOKUP REF Error

Two conditions that cause the VLOOKUP REF error to occur, all related to the table_array column. The following article discusses in detail with a solution to prevent it.

VLOOKUP VALUE Error

VLOOKUP VALUE Error occurs because the col_index_num value is zero (0) or a negative number

VLOOKUP Error

The image above is an example of VLOOKUP VALUE error because the col_index_num value is 0

VLOOKUP NAME Error

VLOOKUP NAME error rarely happens, except for those who are just learning the VLOOKUP function :). This error occurs because of a typo, it could function name typo or range_lookup value typo, or it could be because the lookup_value is text, written directly in the formula and not enclosed in double quotation marks.

VLOOKUP Error

It’s function name typo, VLOOKUP not VLOOKU.

VLOOKUP Error

You should type FALSE not FALS.

VLOOKUP Error

No double quotes enclosed the lookup_value

VLOOKUP Display a Formula Not the Result

Excel has a feature named Show Formulas. If this feature is active, then all cells containing a formula (without exception) will display the formula instead of the results. This feature activated/deactivated by pressing the CTRL+` (inverse quotes, located above the left tab key).

VLOOKUP Error

The image above shows the Show Formulas feature in an active state. Range H4:H8 which contains the VLOOKUP function displays the formula, not the price, likewise cell H10 which contains the SUMPRODUCT function to calculate the total bill.

There are similar conditions like when the Show Formulas feature is active. A cell is showing a formula not the result, even though the Show Formulas feature is not active.

This condition occurs if a cell/range has been formatted into text before the formula is created. All formula created in that cell/range will display the formula instead of the result.

The video below explains the steps to produce the error:

Format range H4:H8 to text, write the formula, and you got the formula, not the result.

Pay attention to the formula in range H4:H8. The lookup_value that should change when the formula copied does not change, a condition of the VLOOKUP function showing the formula, but the Show Formulas feature is not active.

Pay attention to cell H12, the cell contains a formula but does not display the formula, a sign that the Show Formulas feature is not active, although this sign does not always appear.

If cell H12 has been formatted as text too, then the situation will be the same as when the Show Formulas feature is active. Make sure the Show Formulas feature is not active before correcting this problem.

The Solution

The solution is easy. Return H4:H8 cell format from text to number, re-edit the formula in cell H4 then press the ENTER key, do a copy (CTRL+C) in cell H4 then do a paste (CTRL+V) in range H5:H8. Viola, you got the prices 🙂

For a clear explanation, see the video below.

VLOOKUP Results Cannot be Processed

There is a condition that the VLOOKUP function has been created correctly but still produces #N/A error. The cause is lookup_value does not exist in the first column of table_array.

A problem arises when another formula uses the VLOOKUP result. The picture below shows the total bill became NA error because one of the VLOOKUP function returns NA error. What should do to make the overall bill return the actual value instead of NA error?

VLOOKUP Error

There are three solutions to solve this problem, the article below explains in detail every solution that exists. Which one is your choice?

Be Careful with the Fourth Argument

The fourth argument is the range_lookup argument. Most formulas that use the VLOOKUP function always use the FALSE value for the fourth argument.

Why must be careful with the fourth argument? Because the range_lookup argument is optional, you can use it or not. If not using it, by default Excel will use the TRUE value even though TRUE value is “rarely used” for range_lookup argument.

To avoid errors, make sure you always use the fourth parameter, so Excel doesn’t use the default value. If you want to look up the exact match data, then use the FALSE value. If you’re going to look up the approximate match data, then use the TRUE value.

Related Article

Usefull links
  • How to Correct NA Error in the VLOOKUP function

The post VLOOKUP Error – Frequently Error and Solution appeared first on ExcelCSE.com.

]]>
VLOOKUP REF Error – Causes and Solutions https://excelcse.com/vlookup-ref-error-causes-and-solutions/ Fri, 21 Dec 2018 01:00:07 +0000 https://excelcse.com/?p=964 VLOOKUP REF Error because one or more table_array column is deleted Deleting table_array column causes VLOOKUP REF error when the col_index_num value becomes greater than the number of columns in table_array. This error occurs when VLOOKUP formula has already written; then someone deletes one or more column in table_array. For example, there is data as shown below. The VLOOKUP function is used to find the prices on the bill with the col_index_num value is 2 (price for tall size). When will the VLOOKUP REF error occur? No REF error when venti price deleted. The number of table_array columns changes from

The post VLOOKUP REF Error – Causes and Solutions appeared first on ExcelCSE.com.

]]>
VLOOKUP REF Error - Causes and Solutions

VLOOKUP REF Error

VLOOKUP REF Error because one or more table_array column is deleted

Deleting table_array column causes VLOOKUP REF error when the col_index_num value becomes greater than the number of columns in table_array. This error occurs when VLOOKUP formula has already written; then someone deletes one or more column in table_array.

For example, there is data as shown below.

VLOOKUP REF Error

The VLOOKUP function is used to find the prices on the bill with the col_index_num value is 2 (price for tall size). When will the VLOOKUP REF error occur?

VLOOKUP REF Error

No REF error when venti price deleted. The number of table_array columns changes from 4 columns to 3 columns, still greater than the col_index_num value.

Pay attention to the price on the bill, still showing the price for the tall size.

VLOOKUP REF Error

No error too when Grande price deleted. The number of table_array columns changes to 2 columns, equal to the col_index_num value. Prices on the bill keep showing prices for a tall size.

VLOOKUP REF Error

VLOOKUP REF error occurs when the number of table_array columns only leaves 1 column, less then col_index_num value.

VLOOKUP REF Error because the col_index_num value is greater than the number of columns in table_array

This error occurred not because the table_array column was deleted. This error appears more often when writing the VLOOKUP function for the first time. If the col_index_num value is greater than the number of table_array columns, VLOOKUP REF error immediately appeared.

Look at the image below. The VLOOKUP function in cell H4 returns a #REF! error, because the col_index_num value is 5, greater than the number of table_array columns (4 columns).

VLOOKUP REF Error

The solution is easy. Use a col_index_num value less than or equal to the number of table_array columns

Be careful when deleting the table_array columns

When deleting a table_array column in the example above, the prices on the bill does not change, keep showing the price for the tall size. What if the first deleted column is for the tall price column?

Did an error occur?

VLOOKUP REF Error

There was no error because the col_index_num value is still smaller than the number of table_array columns.

But, look at the prices on the bill — all prices changes, showing the prices for a grande size. Prices change automatically is a dangerous condition, no error message but the billing prices changes.

The Solution

Use VLOOKUP MATCH Formula to avoid REF error, and automatically change for VLOOKUP return values when someone deletes one or more table_array columns.

Read the article below for a detailed explanation.

There are many possible errors when using the VLOOKUP function. For errors other than REF error please read the following article:

Related Function

Function used in this article
Usefull links
  • How to Correct #REF Errors

The post VLOOKUP REF Error – Causes and Solutions appeared first on ExcelCSE.com.

]]>