Excel Pivot Tables, Search and Logic Functions, Macros

Classified in Computers

Written at on English with a size of 16.44 KB.

Explanation

10.1 Pivot tables

What is a pivot table? It is one of the most powerful tools in Excel. They are also called “dynamic” because the data on them can be changed by rearranging or changing the position of the column and row headers in an easy and quick way.

The use of a dynamic table is to obtain information summaries from our data grid in order to be able to quickly analyze big volumes of information. These type of tables can be used in situations such as:

  • When you have a table with rows that have different date and you need to organize the information by time periods (month, semester, etc.)
  • When you need to change the arrangement in the rows or column cells to show different perspectives from the same data set.


Follow these steps to create a pivot table in Excel:

  1. Follow the path Insert > Tables > Pivot table
  2. A dialog box will be opened. This box will allow you to enter the data origin and the destination cells:

    e10-1.png
  3. Select the origin data range. This will feed your pivot table.
  4. Select the destination cells. You can select only the first cell of your pivot table.
  5. Click OK.


You should see that a blank pivot table is created and the Pivot Table List panel is shown with the fields available for selection ready to be dragged and dropped into the rows of column labels.

You have two options to add the data into the actual pivot table:

  • Drag the field names into the Pivot table area on the worksheet.
  • Drag the field names into the Pivot table panel areas at the bottom. These areas are linked to the actual worksheet area. As you add the fields into the areas, the table will start populating.


e10-2.png

A pivot table can be sorted and filtered once created. Even more, it can be changed just by moving the data source into another field or column. A pivot table can be also formatted with styles to add a personalized look.

You can also apply filters in a pivot table. To do this, click on the arrow next to Column Labels, to display the list where you can find the Label Filters or Value Filters options. Choose one according to your information needs.

To obtain averages on a pivot table, position the cursor in the Total Sums that Excel generates, so you can modify it. It is important to place the cursor right at the cell you want to modify and then right click to display the options menu. Select the Value Field Settings option and once you see a new dialog box, select the function you want to calculate, Sum, Count Average, or other. In this case select the Average option and click OK. It can also be set via the Field Settings button.

You can also create a chart from your Pivot Table, position in the Options/Analyze tab and then click on the Pivot Chart button. The Insert Chart dialog box will appear; select the features of your graph. When done, click on the OK button.

To delete a Pivot Table select the Options tab and then in the Actions group display the menu, select Delete and then click Clear All.

10.2 Search and Logic Functions

The search and logic functions allow you to perform certain operations with the data contained in a spreadsheet.

The search functions help you to find text or numeric values ​​entered in an Excel spreadsheet according to user requirements and criteria used in the syntax. Below you will see them with some examples:

Function

Description

Example

LOOKUP

Searches for a value within a row or column.

LOOKUP(lookup_value, lookup_vector, [result_vector])
LOOKUP(5, A1:A9, B1:B9) = Find the value 5 in the range A1: A9 and if found returns the value in the same row but the range B1: B9

VLOOKUP

Finds a value in a column and returns the value in the same position in a second column. Always look at the first column in the specified range.

VLOOKUP(lookup_value, table_array,col_index,num, [range_lookup])
VLOOKUP(“Friend”, A1:B10, 2) = Find "Friend" in column A and returns the value that corresponds to the column B

HLOOKUP

Finds a value in a row and returns the value in the same position in a second row. Always look on the front row of the specified range.

HLOOKUP(lookup_value,table_array,row_index_num[range_lookup])
HLOOKUP(“Excel”, A1:J2, 2) = Find "Excel" in row 1 and returns the value that corresponds to row 2

MATCH

Searches for a value in a list and returns the relative position of the value within the range.

MATCH(lookup_value,lookup_array,[match_type]
MATCH(“Friend”, A1:A10, 0) = Find "Friend" in column A and returns the position in the list where the value was found

COUNT

Counts the number of cells that contain numbers in a given range.

COUNT(value1, [value2], …)
COUNT(A1:A5) = Count cells within the range A1: A5 containing numbers

The logic functions are used in the decision-making, because according to the result of the function we will have to make a decision.

Function

Description

Example

IF

Evaluates a condition and returns one value if the condition is true, and another value if the condition is false

IF(logical_test,[value_if_true].[value_if_false]
IF(“1IF(“1>2″, “Excel”, “Total”) = Total

AND

Returns the value TRUE if all parameters are true, or returns FALSE if either parameter is false.

AND(logical1, [logical2], …)
AND(TRUE, TRUE) = TRUE
AND(TRUE, TRUE, TRUE) = TRUE

OR

Returns the value TRUE if either parameter is true, or returns FALSE if all parameters are false.

OR(logical1, [logical2], …)
OR(TRUE, FALSE) = TRUE 
OR(FALSE, FALSE) = FALSE

NOT

Reverses the logical value of the specified argument

NOT(logical)
NOT(TRUE) = FALSE
NOT(FALSE) = TRUE

10.3 Creating and Editing Macros

macro is a set of repetitive instructions or actions that are saved to be available whenever they are needed to be executed. Macros help us out to automatize tasks that are done repetitively.

The easiest way to create a macro is by using the macro recorder tool. In order to be able to create macros, make sure that the Developer tab is available on the ribbon as this is where the macro commands are. If you don’t see it in your ribbon, perform the following steps to make it visible:

  1. Click on the File tab.
  2. Click on the Options item.
  3. Click on Customize Ribbon and select the Developer checkbox on the list at the right:

e10-3.png

  1. You should be able to see the Developer tab now:

e10-4.png

Recording a macro.

With this option, each of the commands performed by you will be recorded and executed again to repeat them as needed.

  1. Click on the Record Macro button.
  2. Enter Macro name (without spaces) and description and hit the OK button. When hitting OK the events that happen will start recording.
  3. Once you are finished click on the Stop recording.


Modifying a macro.

If there are existing macros that almost fit what you are trying to accomplish you can always edit them. In order to modify macros:

  1. Click on the Macros button in the Code tools group.
  2. Select the macro you wish to edit and click on the Edit button.
  3. You will see that the Visual Basic editor will be opened. This is the programming language in which macros are created and you will need a little knowledge on this to be able to create your own macros. The "Sub” (subroutine) line indicates the name of the macro and each macro ends on the “End Sub” line.

Entradas relacionadas: