2. Table of
Contents
1
+ Introduction to Excel Formulas
• What is a function ?
• Types of functions in MS excel
• Function categories with examples
• Features of Excel to analyze the data
• Formulas that can be build in excel with pre-defined function
+ Introduction to Excel Macros
• What is a macro?
• How to enable a macro?
• How to record and replay a macro?
• How to extract data using a macro?
• Basics of VBA
• Example
4. 3
Functions are predefined formulas that are already available in excel.
What is a function?
• Excel has got over 400 pre defined formulae's such as (sum, if, VLOOKUP),these are technically referred to as function.
• How to access the predefined functions in excel ?
• Difference between formula and function in excel ?
• A formula is any calculation in excel, but a function is a predefined calculation.
• Example- =A1/A2 is a formula
=MAX(A1:B20) is a formula containing a MAX function.
5. 4
The function can be Broadly categories into FIVE categories.
• LOOKUP FUNCTION- VLOOKUP
HLOOKUP
• TEXT FUNCTION – TRIM
LEN
CONCETNATE
• LOGICAL FUNCTION- AND
IF
OR
• DATE FUNCTION- DATEDIF
EDATE
• MATHEMATICAL FUNCTION- COUNTIF
Type of functions
6. 5
VLOOKUP-. The VLOOKUP (Vertical lookup) function looks for a value in the leftmost column of a table, and then returns a
value in the same row from another column you specify.
In simple words ,VLOOKUP is used to look up a value from a different location in your workbook. It’s useful because when
dealing with large amounts of data because you always need to look things up.
Syntax- =VLOOKUP(ItemToFind,RangeToLookIn,ColumnToPickFrom,Rangelookup)
Lets break the syntax into parts .
1. ITEM TO FIND -The value you want to look up LOOKUP_VALUE
2. RANGE TO LOOKIN-The table of data you want the information retrieved from. The ‘look up table’ TABLE_ARRAY.
3. COLUMN TO PICK FROM-The column containing information you want to bring back. The column
number column COL-INDEX-NUM.
4. Rangelookup – this is also known as True or false, TRUE will look for the value closest while FALSE will look for an
exact match.
LOOKUP FUNCTION
7. 6
• When we have a large data set of patents in a file and we need to find a specific information about a patent number we
can use a VLOOKUP.
• EXAMPLE – From the given set of patents ,we need to find the secondary status for
TW200412944,TW200412961,TW200412962.
Lets see how it works
8. 7
A new dialog box
will appear.
Add the arguments in the lookupvalue,table array ,columns index num,and
range lookup value column.
9. 8
• Lookup value-Patent number that we want to lookup(h2)
• Table array- the table from where we want to retrieved
the information (a2:b10).
• Column index –the secondary status information column
that we are looking for (2).
• Range lookup-either true or false (false for exact
information).
• Press OK.
10. 9
HLOOKUP-. The HLOOKUP function looks for a value in the topmost row of a table, and then return a corresponding value
in the same column from a row.
• The HLOOKUP is a sibling of VLOOKUP function, the H in the HLOOKUP stands for “Horizontal” and hence it is often
called as Horizontal lookup
• Horizontal Lookup performs a case insensitive lookup. This means, it treats “STEVE” and “steve” as same.
• ‘range lookup’ is an optional argument. If it is omitted then HLOOKUP takes its default value as TRUE (approximate
match).
Syntax- =HLOOKUP(ItemToFind,RangeToLookIn,RowToPickFrom,Rangelookup)
Lets break the syntax into parts .
1. ITEM TO FIND -The value you want to look up LOOKUP_VALUE
2. RANGE TO LOOKIN-The table of data you want the information retrieved from. The ‘look up table’ TABLE_ARRAY.
3. COLUMN TO PICK FROM-The containing information you want to bring back. The row number row ROW-INDEX-NUM.
4. Rangelookup – this is also known as True or false, TRUE will look for the value closest while FALSE will look for an
exact match.
11. 10
Consider ,we have a student marks table and we need to find the Chetana marks in computer.so, for this we can use
HLOOKUP.
Lets see how it works
How to add H
LOOKUP?
12. 11
Add the arguments in the lookup value, table array, row index
num and in range lookup column.
• Lookup value-Student name that we want to lookup(b7)
• Table array- the table from where we want to retrieved
the information (c1:14).
• Row index –the computer marks information row that we
are looking for (4).
• Range lookup-either true or false (false for exact
information).
• Press OK.
14. 13
LEN- This function counts the number of characters, including spaces and number, in a piece of text.
Syntax- LEN(TEXT)
When to use – when we have a data set and we want to calculate the number of characters in the given data set .we can
use LEN function
EXAMPLE – From the given patent data set ,we want to calculate the number of characters of the given patent number .
TEXT FUNCTION
Excel has many functions to offer when it comes to manipulate text strings.
15. 14
• Apply the syntax - =LEN(Column number )
=LEN(A5)
• Press ok.
We can get the number of
characters in A5 columns -12.
16. 15
TRIM-This function removes unwanted spaces from a piece of text.
• The spaces before and after the text will be removed completely.
• Multiple spaces within the text will be trimmed to a single space.
Syntax- =TRIM(TexttoTrim)
EXAMPLE- From the given patent data set we want to clear the unwanted space in the patent number column.
To access TRIM function, go to Formulas bar
and then to text and choose TRIM Function.
17. 16
• Apply the syntax- =TRIM(A2)
• Press ok
We can eliminate the extra space.
18. 17
CONCATENATE- This function joins separate pieces of text into one item.
• CONCATENATE can join up to 30 text items together.
• Text items can be text strings, numbers, or cell references that refer to one cell.
Syntax- =CONCATENATE(Text1,Text2,Text3...Text30).
EXAMPLE- From the given patent data set ,we want to join the primary and secondary status of a given set of patent .
To access concatenate function,
go to formula bar ,then select text
option and go to CONCATENATE
19. 18
• Apply the CONCATENATE-B2(Primary Status)
( (open bracket)
) (close bracket)
C2 (Secondary Status)
We will get the primary status and secondary
status of patent CONCATENATE.
20. 19
AND FUNCTION-This function tests two or more conditions to see if they are all true
• It can be used to test that a series of numbers meet certain conditions.
• It can be used to test that a number or a date falls between an upper and lower limit.
• When it is used by itself it will show TRUE OR FALSE.
• But, Normally the AND() function would be used in conjunction with a function such as =IF().
Syntax- =AND (TEST1,TEST2)
• Note that there can be up to 30 possible tests
EXAMPLE - In the given Patents data set ,we want to see that the expiry dates that we have got for a set of patents are
recorded according to the united kingdom patent expiry rules or not and is their filing date is after 31/5/1983,so that we can
the AND FUNCTION.
LOGICAL FUNCTIONS
21. 20
Apply the function
• B2 IS Filling date
• In 20 years we have 730 days
• C2 Is given expiry date
• So we apply =AND (B2+7305=c2)
• And we also need to find that filing date is after 31/5/1983
• So we add up in the same and formula =AND(B2+7305=C2,AND(B2>”1983-5-31”))
• If it follow the rule then it will give TRUE else FALSE.
22. 21
We get to know that are the patents following the EP
rule and is their filing date is after 31/5/1983.
23. 22
IF FUNCTION-The IF function can perform a logical test and return one value for a TRUE result, and another for a FALSE
result.
How the function works -
• This function tests a condition.
• If the condition is met it is considered to be TRUE.
• If the condition is not met it is considered as FALSE.
• Depending upon the result, one of two actions will be carried out.
Syntax- =IF(Condition,ActionIfTrue,ActionIfFalse)
• The ActionIfTrue and ActionIfFalse can be numbers, text or calculations.
EXAMPLE- we have a given set of patents number and we need to find the error in their expiry dates according to united
kingdom expiry rules .
24. 23
Apply the function-
• In 20 years there are 7305 days ,than f.d+7305=true
• If the days will be 7304 days ,than f.d +7304=EP patents with -1 days
• And if there are some other date except above two condition, than result will
be false
25. 24
We get the correct expiry dates status
according to U.K Rules
26. 25
DATEDIF -This function calculates the difference between two dates.
• It can show the result in weeks, months or years.
Syntax- =DATEDIF(FirstDate,SecondDate,"Interval")
Lets break the syntax into parts
• First Date : This is the earliest of the two dates.
• Second Date : This is the most recent of the two dates.
• "Interval" : This indicates what you want to calculate.
These are the available intervals-
DATE FUNCTION
The DATE function is a built-in function in Excel that is categorized as a Date/Time Function. It can
be used as a worksheet function (WS) in Excel.
27. 26
EXAMPLE- we need to find out the difference between patent expiry date and extension date in terms of years from the
given patent data set
Apply the function-=DATEDIF
• B2-EXPIRY DATE
• C2-EXTENSION EXPIRY DATE
• Y-DIFFERENCE IN YEARS
We can get the difference
between two date in terms of
years.
28. 27
EDATE- This function is used to calculate a date which is a specific number of months in the past or in the future.
• The result will normally be expressed as a number, this can be formatted to represent a date by using the
Format,Cells,Number,Date command.
Syntax- =EDATE(StartDate,Months)
EXAMPLE- For the given patent set of data ,the extension is provided in terms of months and we need to calculate the
extension expiry date by using the EDATE formula .
29. 28
Apply the Function- =EDATE
B2-Expiry date to which extension months will
be added.
C2- Extension months to be added
PRESS OK.
we get the EXTENSION EXPIRY
DATE.
30. 29
COUNTIF- This function counts the number of items which match criteria set by the user.
• COUNTIF can be used to count cells with dates, numbers, and text that match specific criteria.
• The COUNTIF function supports logical operators (>,<,<>,=) and wildcards (*,?) for partial matching.
Syntax- =COUNTIF(RangeOfThingsToBeCounted,CriteriaToBeMatched)
EXAMPLE- In the given patent data set we need to find the following things-
MATHEMATICAL FUNCTIONS
Mathematical Formulas in Excel are used to perform various arithmetic operations like adding
the values in a range of cells, finding average of selected cells etc.
31. 30
Apply the function –
=COUNTIF
• Select the range of sheet in
which you want to search
the patent number (a2:c14)
• Type the name of “patent
number” you want to search
(EP0200322)
• PRESS OK
Apply the function – =COUNTIF
• Select the range of sheet in
which you want to search the
DRUG (a2:c14)
• Type the name of “DRUG” you
want to search
(LERCANIDIPINE)
• PRESS OK
32. 31
We get the number of time “EPO200322” ,”LERCANIDIPINE” is repeated also we are able to find the number
of dates before “5/1/2006” in expiry date column.
33. 32
HIGHLIGHT THE DUPLICATES VALUE – TO find the duplicates value in the given set of data .
CONDITIONAL FORMATTING
Conditional formatting in Excel enables you to highlight cells with a certain color, depending on the cell's value
Select the entire
set in which u need
to find the
duplicates
34. 33
2. On the Home tab, in the Styles group, click Conditional Formatting
3. Click Highlight Cells Rules, Duplicate Values.
4. Select a formatting style and click OK.
36. 35
• Text to Columns can be used to separate data in a single column into multiple columns, such as if you have full names in
one column and need a column with first names and a column with last names.
EXAMPLE- we have patent data set in which the primary status and secondary status of a patent are mentioned in one
column and we need to separated them into two different columns.
How to access the text to column function –
• Go to data bar,datatools ,Text to column, the text to column wizard opens
TEXT TO COLUMN FUNCTION
37. 36
• A new dialog box
will open.
• Select space from
the options
• Press next
38. 37
The primary and secondary
status get separated into tow
columns
• Select general from column
data format
• Press Finish.
39. 38
• In the U.K project ,we have the EP AND GB Designated patents, and we need to find the correct expiry date of the
patents, and the errors in the data we have received .
Use of Excel function in Patent Data checks
40. 39
First ,we need to apply Text to column
function to separate the patent expiry
date and extension date .
So after applying the text to
column section
(delimited),we got the two
dates separated.
Then, apply CONCATENATE to combine
drug name with the patent number so that
we can find the duplicates can eliminate
the them.
41. 40
• Apply IF function to get the errors in the expiry date of the patents ,before this the expiry check rules for u.k are –
• According to these rule apply IF function to create a formula to get the Errors in the Expiry date of patents .
• Normal syntax for IF function - = IF(Condition,ActionIfTrue,ActionIfFalse)
• Formula framed by using IF function - =IF(J1="EP",IF(K1+7305=O1,"True",IF(K1+7304=O1,"EP patent with -1
day","False")),IF(J1="GB",IF(K1+7304=O1,"True",IF(K1+7305=O1,"GB without -1 day",IF(K1+5843=O1,"Older GB
patent expiry OK","False")))))
42. 41
EP PATENTS -
In 20 years the number of days -7305-condition will be true
In 20 years (-1) number of days -7304- condition will be EP (-1) Day.
If number of days are not the above one –condition will be false
GB PATENTS-
In 20 years the number of days -7305-condition will be GB Without -1 day
In 20 years (-1) number of days -7304-condition will be true.
For older GB Patents –
For patents filed before 1 June 1967 –filing date +16(-1 day)-condition will be older gb patents expiry ok
If any of the condition is not matching for the GB patents –condition will be false
• Final formula - =IF(J1="EP",IF(K1+7305=O1,"True",IF(K1+7304=O1,"EP patent with -1
day","False")),IF(J1="GB",IF(K1+7304=O1,"True",IF(K1+7305=O1,"GB without -1 day",IF(K1+5843=O1,"Older GB
patent expiry OK","False")))))
• * We can also used the EDATE FUNCTION in case if we want to add years (20or 16) instead of days that we have used
in formula .
Apply the formula in excel sheet and we will get the errors in the expiry date of EP OR GB patents designated to U.K.
43. 42
We got the errors in the expiry dates ,and we can correct
them by adding or subtracting 1 day for (EP Patent with -1
day ,GB Patents without -1 day ),and we can correct the
false expiry by following the U.K expiry rules .
48. 47
For Germany we can apply all these strategies to mark the errors in their Expiry dates and to sort data –
• Remove the duplicate
• Separate the patent expiry date from(PAT)
• Follow the Germany expiry rules ,to build a Expiry formula
• Mark the incorrect expiry and make them the correct
• Germany expiry RULES –
.
EXCERCISE
50. 49
A brief intro
What is a macro?
• Macros are little programs that run within Excel and help automate common repetitive tasks.
• Macros are one of Excel’s most powerful, yet underutilized feature.
• Using macros, you can save hours and boost productivity manifold.
• Different ways to use a macro:
- Record a macro
- Write a command in VBA
60. 59
A brief introduction:
Basics in VBA
• Excel VBA means Excel Visual Basic for Applications which can be created using the built-in Visual Basic Editor in
Microsoft Excel.
• VBA is not just for repetitive tasks though. We can also use VBA to build new capabilities into Excel and to perform tasks
that integrate Excel with other Office applications such as Microsoft Access 2010.
• For example, you could develop new algorithms to analyze your data, then use the charting capabilities in Excel to display
the results.
61. 60
Example: A modified macro for processing Belgium Database
http://bpp.economie.fgov.be/fo-eregister-
view/application?lng=fr&number=EP2214636