Author: Aniruddh

  • Learning Excel Table Features-Introduction

    Excel Tables are defined as the series of rows and columns with related data which can be managed independently. In the processor of learning Excel, Excel Table is very important because it is a very useful and a powerful tool of Excel.

    Excel tips on Excel Tables
    Excel Table Example

    What is Excel Tables? What are the advantages of using the Excel Tables?
    You might be thinking on these questions. For better understanding, let us look into a simple example. We have a data in the range A1 to E20 which talks about the different products, their price variations.  By using Table, we are telling the excel that, The cells from A1 to E20 has related data and row 1 has table headers. Currently data is in only 19 rows. However it can be increased later. When you make a table in Excel, you can add rows without worrying about updating the formula references,  formatting of cells, Filter settings etc.
    Key Advantages of Excel Tables:

    • Activating any cell in the table gives the access to a new Table Tools contextual tab on the ribbon
    • Provides option to quickly apply background color and text color formatting by choosing from the gallery  This formatting is optional.
    • Each column header contains a drop down list which you can use to sort the data or filter the table to hide specific rows.
    • If you scroll down the sheet so that the header row disappears, the table headers replace the column letters in the worksheet header. In simple words, you don’t need to freeze the top row of the table to keep the column labels visible
    • Tables support calculated columns. A single formula in a column is automatically propagated to all cells in the column.
    • Excel Tables supports structured references. Instead of using the cell references formula can use table names and column headers
    • When you move your mouse pointer to the lower right corner of the lower right cell, you can click and drag to extend the table’s size, either horizontally(add more columns) or vertically(Add more rows).
    • Selecting the rows and columns within the table is simplified
    Disadvantages or limitations of Excel Tables:
    • When a workbook contains atleast one table, Excel doesn’t allow you to use the custom views features(choose view->Workbook Views-> Custom Views).
    • You cannot insert automatic subtotals within a table(by choosing Data->Outline->Subtotal)
  • Excel Formula to return the last nonblank cell in a column or Row

    Some times in Excel worksheet which we update frequently by adding new data to its columns and we need to reference the last value in a particular column. That is the value most frequently entered. We can achieve this combining two excel worksheet formulas COUNTA and INDEX. The source of this tips is John Walkenbach’s Excel 2010 Tips &Tricks book. To learn about find the last row using Excel VBA click here.

    Below is the simple example with a excel worksheet which tracks the value of three funds in columns B to D. The data updates each and every month. The motto is to get the latest value for each fund and add the values of this.These value will be updated in the cells G2:G4.

    Returning last Columns value in Excel
    The Excel formula used in G2,G3,G4 are as follows.
    =INDEX(B:B,COUNTA(B:B))
    =INDEX(C:C,COUNTA(C:C))
    =INDEX(D:D,COUNTA(D:D))

    Explanation on how this Excel Formula works: The COUNTA worksheet formula used above counts the number of non empty cells in the selected Column.Then this value is used as the second argument for INDEX worksheet function.  In the the first formula, in column B the last value is in row 6 hence COUNTA returns 6  and the INDEX function returns the 6th value in the column.

    The above formula works on most of the situations. However, if the column has one or more empty cells interspersed(Empty cell in between the cells which has values), determining the last nonblank cells is challenging as COUNTA function doesnot count the empty cells.
    The following array formula returns the content of the last non empty cell in the first 1000 rows of column C, even if column C contains blank cells.
    =INDEX(C1:C1000,MAX(ROW(C1:C1000)*(C1:C1000<>””)))
    Note: As this is a Array formula of Excel, you need to press Ctrl+Shift+Enter instead of just Enter. Otherwise it given wrong output.
    You can change the formula to work with a column other than column C. To use a different column, change the column reference from C to whatever column you need. If the last non empty cell occurs in a row beyond row 1000, you need to change the two instances of 1000 to a desired row number. The fewer rows referenced in the formula, the faster the calculation speed.
    To return the last non empty cell in a row, you need to use following excel array formula. It works similar to above formula, but finds last row instead of last column(In this example, row 1.
    =INDEX(1:1,MAX(COLUMN(1:1)*(1:1<>””)))
    to use this formula for a different row, change the the three 1:1 row references to correspond to the correct row number.

  • How to Perform two column Lookup on Excel

    The VLOOKUP function in excel does not handle multiple criteria by default. However, with little tweaking the source data or with the help array formula we can perform multi condition lookup. In this post, we will learn the way to do two column lookup on Excel.

    Let us take a sample data.

    Perform two column Lookup on Excel

    To make this formula we have defined user named ranges.

    Range(C4:D6) is named as lookup_Table

    Other related posts:

    VLOOKUP in EXCEL Tips and Tricks

    ROW and Column VLOOKUP

    Perform two column multi condition vlookup using the helper column

    As VLOOKUP does not take multiple criteria, we need to insert a new column called helper Column. In this column we need to concatenate the fields of two column. In our example, we have concatenated Brand and Model using the formula concatenate or with the help of “& “.

    Formula in cell C4 is

    =A4&B4

    Final vlookup formula is

    =VLOOKUP(G3&G4,lookup_Table,2,FALSE)

    How this conditional vlookup works

    In the example, we want to lookup price using vlookup based on brand and model.

    One of the limitation of VLOOKUP is it handles only one condition. The lookup value will be searched in first column of the selected data range. To overcome this limitation, we are using the helper column.

    In the helper column, we have concatenated the Brand and model. The lookup value also we have joined together. In the example, VLOOKUP searches for BajajPulsor in the range C4 to C16. It is there in 9 the row. Now it will return the corresponding value in 2nd column. That is 53000.

  • Excel formula to count the Characters in cell based on different criteria

    There is a direct Excel formula to count the number of characters in a cell. However, we sometimes come under a situation where we need to count a specific character in a cell or an occurrence of a substring in a cell.  Here are the steps to achieve these requirements.

    Counting all the characters in a Cell

    To count the number of characters in a cell, there is an Excel function called LEN. 

    Syntax of LEN function

    =LEN(text)

    Examples for using Excel LEN function:

    =LEN(A1)- it counts the number of character in Cell A1

    =LEN(“Apple”)- counts the number of characters in the word “Apple”

    Counting a specific characters in a Cell

    To count a specific character in a cell, we need to use substitute and upper functions along with LEN function.

    Example:

    Let us consider we have a word “Apple” in Range A1 and we need to calculate the number of instances of “P”.

    =LEN(A1)-LEN(SUBSTITUTE(UPPER(A1),”P”,””)) which returns 2.

    This formula calculates the number of instances of “P” irrespective of case. If you want this formula to be case sensitive then formula becomes as mentioned below.

     =LEN(A1)-LEN(SUBSTITUTE(A1,”p”,””))

    Explanation:

    The Formula counts the total number of characters in the cell and subtracts the count of character of the cell excluding the character we need to calculate the count. Here SUBSTITUTE function is used to exclude the character “P”. SUBSTITUTE function is case sensitive; hence we have used “UPPER” function which makes all the characters in the cell to upper case in the first example. 

    Counting the occurrences of a substring in a cell

    Below example demonstrates on how to calculate the count of a specified string(more than a character) in a cell. 

    =(LEN(A1)-LEN(SUBSTITUTE(UPPER(A1),UPPER(B1),””)))/LEN(B1)

    In this example, the main string is in Cell A1 and the substring which we need to count is in cell B1.  For example. Cell A1 contains “Excel to Excel” and B1 contains “Excel” then the result is 2. The formula is not case sensitive. If you want to the formula to be case sensitive, then remove UPPER function which looks like below.

    =(LEN(A1)-LEN(SUBSTITUTE(A1,B1,””)))/LEN(B1).

  • Different ways of using Single Criterion SUM function in Excel

    We have already seen the basic syntax and how to use single criteria SUM in Excel. In this post, we will see how use conditional sum based on difference scenarios. For detailed explanation on SUMIF function please read here.
    Examples for Using conditional sum Excel Function SUMIF: Below are the some of the Excel example based on different situations.

    Conditional sum Sample data
    Sample Data

    1. Summing only Negative OR Positive values using Excel SUMIF Function:

    The below formula will add the “difference” column values whichever is less than zero.
    =SUMIF(E2:E20,”
    Similarly you can add the values with positive value.
    =SUMIF(E2:E20,”>0″)

    Now if we want to find the total variations, we need to sum all negative values and positive values. Below is the formula to find total sum considering absolute values.
    =ABS(SUMIF(E2:E20,”0″) which returns 86. Here we did calculate the sum of both negative and positive values and then added these two making negative values absolute. 

    Note: The SUMIF function can use three arguments. However it is not mandatory to use third argument. If we omit the third argument, then Excel adds the values in the 1st argument when the criteria is met.

    2. Summing values based on a different Range:  For this we need to use the third argument of SUMIF functions.  As we know, first argument is the range which should be matched with the criteria(argument 2) and the third argument is the range which should be added when given criteria is met. Following SUMIF formula demonstrates the same.
    =SUMIF(E2:E20,”>0″,C2:C20) which returns 940. In this example, excel adds the “price” where the difference has positive value(Greater than Zero).
    3. Summing Values based on a text comparison: Some times we need to compare the text value of a range and then perform SUM.  Following are examples for the same.

    =SUMIF(A2:A20,”Apple”,C2:C20) which returns 444. This formula adds the range “Price” when “Data” Column has the text “Apple”.
    =SUMIF(A2:A20,”<>Apple”,C2:C20) which returns 997.This formula adds the range “Price” when “Data” Column does not contains text “Apple”.

    4. Summing Values based on a date Comparison: We can use Excel SUMIF formula to add the values based on given date criteria. Following is the example for the same.
    =SUMIF(B2:B20,”>=”&DATE(2013,1,7),C2:C20) which returns 790.
    =SUMIF(B2:B20,”>=”&TODAY(),C2:C20) which returns 217.

    Note: As you might have observed, we have used a expression as a second argument which is a criteria. The expression used in first example is DATE and in second it is Today().DATE function returns the date and Today function returns Todays date.  Also the comparison operator, enclosed in a quotation mark is concatenated using & operator with the result of the DATE or TODAY() function.

    Please share your thoughts or queries on these examples and also share any tips for using SUMIF function you might know in the comment section.0>0>