Excel Formulas: 140 Excel Formulas and Functions...
Transcript of Excel Formulas: 140 Excel Formulas and Functions...
ExcelFormulas140ExcelFormulasandFunctions
withusageandexamplesByVijayKumar
Copyright©2016AllRightsReserved.
Nopartofthisbookmaybereproducedinanyformorbyanymeans,includingscanning,photocopying,orotherwisewithoutpriorpermissioninwriting
fromtheCopyrightholder.
Introduction
ThingstorememberwhileenteringFormulas.
Usingcalculationoperatorsinformulas
TypesofOperators
Excelcalculationorder
CommonmistakeswhilecapturingFormulas.
HowtoforceExcelFormulastorecalculate?
FormulaerrorsinExcel.
DebuggingFormulas
HowtouseThisBook
1.Compatibility
1.1MODE
1.2.RANK
2.Dateandtime
2.1.DATE
2.2.DATEVALUE
2.3.DAY
2.4.DAYS
2.5.DAYS360
2.6.EDATE
2.7.HOUR
2.8.MINUTE
2.9.MONTH
2.10.NETWORKDAYS
2.11.NETWORKDAYS.INTL
2.12.NOW
2.13.SECOND
2.14.TIME
2.15.TIMEVALUE
2.16.TODAY
2.17.WEEKDAY
2.18.WEEKNUM
2.19.WORKDAY
2.20.WORKDAY.INTL
2.21.YEAR
3.Engineering
3.1.CONVERT
4.Financial
4.1.FV
4.2.PMT
4.3.IPMT
4.4.PV
4.5.NPER
4.6.RATE
5.Information
5.1.CELL
5.2.INFO
5.3.ISBLANK
5.4.ISERR
5.5.ISERROR
5.6ISEVEN
5.7.ISFORMULA
5.8.ISLOGICAL
5.9.ISNA
5.10.ISNONTEXT
5.11.ISNUMBER
5.12.ISODD
5.13.ISREF
5.14.ISTEXT
5.15.N
5.16.NA
5.17.TYPE
6.Logical
6.1.AND
6.2.IF
6.3.IFERROR
6.4.NOT
6.5.OR
6.6.FALSE
6.7.TRUE
6.8.IFNA
7.Lookupandreference
7.1.ADDRESS
7.2.AREAS
7.3.CHOOSE
7.4.COLUMN
7.5.COLUMNS
7.6.HLOOKUP
7.7.HYPERLINK
7.8.INDEX
7.9.INDIRECT
7.10.LOOKUP
7.11.MATCH
7.12.OFFSET
7.13.ROW
7.14.ROWS
7.15.TRANSPOSE
7.16.VLOOKUP
8.MathandTrigonometry
8.1.ABS
8.2.AGGREGATE
8.3.CEILING
8.4.CEILING.PRECISE
8.5.COMBIN
8.6.EVEN
8.7.EXP
8.8.FACT
8.9.FACTDOUBLE
8.10.FLOOR
8.11.FLOOR.PRECISE
8.12.GCD
8.13.INT
8.14.LCM
8.15.MOD
8.16.MROUND
8.17.ODD
8.18.PI
8.19.POWER
8.20.PRODUCT
8.21.QUOTIENT
8.22.RAND
8.23.RANDBETWEEN
8.24.ROMAN
8.25.ROUND
8.26.ROUNDDOWN
8.27.ROUNDUP
8.28.SQRT
8.29.SUBTOTAL
8.30.SUM
8.31.SUMIF
8.32.SUMIFS
8.33.SUMPRODUCT
8.34.TRUNC
9.Statistical
9.1.AVERAGE
9.2.AVERAGEIF
9.3.AVERAGEIFS
9.3.COUNT
9.4.COUNTA
9.5.COUNTBLANK
9.6.COUNTIF
9.7.COUNTIFS
9.7.FREQUENCY
9.8.LARGE
9.9.MAX
9.10.MEDIAN
9.11.MIN
9.12.MINA
9.13.SMALL
10.Text
10.1.CHAR
10.2.CLEAN
10.3.CODE
10.4.CONCATENATE
10.5.DOLLAR
10.6.FIXED
10.7.LEFT
10.8.LEN
10.9.LOWER
10.10.MID
10.11.PROPER
10.12.REPLACE
10.13.REPT
10.14.RIGHT
10.15.SEARCH
10.16.SUBSTITUTE
10.17.T
10.18.TEXT
10.19.TRIM
10.20.UPPER
10.21.VALUE
10.22.FIND
Conclusion
AbouttheAuthor
MyOtherBooks.
IntroductionWhyshouldyoulearnExcelFormulas?
Thanksfordownloadingthisbook.
ExcelispartoftheMicrosoftOfficesuiteandtheworld’smostwidelyusedspreadsheetapplicationusedbyMillions.ComparedtootherSpreadsheetprogramsExcelisveryfeaturerichandpopularandincorporatedwithsomanybuiltinFormulasandFunctions.Evenifyoudon’tknowthefunctionnameyoucansimplysearchthewordyouthinkrelatedtoaformulaintheinsertfunctionboxandyouwillgetbacktheFormulasrelatedtothatword.
Thisbookprovidesmorethan140Formulasandthereusewithexamplesforyoutounderstandanduseitinyourdaytodaywork.
PleasekeepinmindsomeofthenewfunctionswillnotworkinyourComputerifyouareusingpreviousversionsofExcel.
ThingstorememberwhileenteringFormulas.FormulacanbeenteredinExcelbyfirstenteringtheequalsign(=)followedbytheformulanamelikethis=SUM(A1:A100),openingandclosingbracketsarecompulsory.Orelseyoucanenteraplussignandtypetheformulaandtheformulawillbeautomaticallyconvertedto=+SUM(A2:A4).ThisisusedforcompatibilityreasonaswhenExcelwasintroducedtheleadingspreadsheetprogramwasusingtheplussign.
Relative,AbsoluteandMixedreferenceAreferencemeansacell(A1)orarangeofcells(A1:A8)onaworksheet,andtellsExcelwheretolookforthevaluesordatayouwanttouseinaformula.
RelativeReference
BydefaultExcelfollowsrelativereference.SayforexampleifyouareaddingtwocellsA1andB1inthecellC1usingtheformula=SUM(A1+B1)andifyoucopydowntheformulatoC2theSumformulawillautomaticallychangethecellreferencerelativelytothenextrowto=SUM(A2+B2).IfyoucopytheformulaacrossthecolumntoD1theformulawillchangetoSUM(B1+C1).
Absolutereference
Absolutereferencemeansthecellreferencewillalwaysrefertothesamecellandforthatyouhavetoputadollarsignbeforethecolumnnameandrownumber.Asintheaboveexampleifyourewritetheformulato=SUM($A$1+$B$1)andifyoucopydowntheformulathecellreferencewillnotchangerelativelyitwillalwaysgetthesumofA1andB1whereveryoupastetheformulainthesheet.
BypressingtheF4keyyoucaneasilyinsertthedollarsignandifyoukeeponhittingtheF4keythereferencewillchangetomixedandtorelative.
Mixedreference
Amixedreferencehaseitheranabsolutecolumnandrelativerow,orabsoluterowandrelativecolumninaformula.Forexample=$A1willalwaysrefertotheAcolumn,sincethereisnodollarsignbeforetherownumberifyoucopyacrosstheformulathecolumnnamewillnotchangebuttherownumberwillchange.
Likewiseifthereisdollarsignbeforetherownumber(A$1)thenthecolumnnumberwillchangeifyoucopytheformulabuttherownumberwillnotchange.
AutocompleteYoucanusetheautocompletefeatureoftheExcelwhileenteringtheformulatospeeduptheFormulacapturing.Forexampleifyouwanttofindthetotalofarangethenyouhavetofirstentertheequalsign(=)followedbyformulanameSUM.WhileenteringtheformulaiftheformulanamecomesupasthefirstoneintheautocompletelistthenyoucanpresstheTABbuttonandExcelwillautocompletetheformulawithopenbracketsandafterenteringtheargumentsyoucanagainpressTABbuttontoautomaticallyclosethebrackets.
Ctrl+EnterIfyouwanttoenterformulatomorethanonecellthenyoucanselecttheentirerangeandentertheformula,insteadofpressingEnteryoucanpressCtrl+Entertopastetheformulasautomaticallytoalltheselectedrange.
CTRL+`(graveaccent)IfyougottheworksheetandwanttoseealltheformulasenteredinthesheetyoucanpressthisshortcutCTRL+`key(justbelowtheESCkeywhichhasalsothetilde(~)character).Alltheformulacellswillexpandtodisplaytheformulaenteredinsteadoftheformulavalues.
MovingandCopyingformulasIfyoumove(cutandpaste)theformulafromonecelltoanotherthentheformulawillrefertothesamecells.Forexampleifyoumove=SUM(A1:B1)fromthecellC1toC8itwillstillrefertothesamecells.
IfyoucopythesameformulafromsameC1TOC8thentheformulawillchangeto=SUM(A8:B8).
F9toevaluatepartsofaformulaSometimesifyouareusinganestedformulalikethis=RIGHT(C22,LEN(C22)-FIND(”“,C22))itwillbeverydifficulttodebugtheformulaifsomethinggoeswrong.InthiscaseyoucanusethefunctionkeyF9toevaluateeachnestedformulas.
Forexampleinthisformula=SUM(A1:B1,D1:D3)ifyouselectthefirstrangeA1:B1andclickF9thenyoucanseewhichallvaluesareusedandifyouagainpressF9thenthevalueswillgethardcodedtotheformula.
FillhandleorusingFillseriesorCntlr+DtofilltheformulaOnceyouentertheformulayoucanusetheExcelfillhandletofilldowntheformula.Onceyoucompletedenteringtheformulagobacktotheformulacellandputthemouse
ontherighthanddowncornerwhereasquaredot isshownandthecursorwillchangetoablackplussignandyoucandoubleclicktheblackplussignandcopytheentireformuladown.
Keepinmindifthereisanybreakinthedata,meansanyrowsareblankExcelwillstopfillingtheformulajustbeforethat.
AlsoyoucanclickontheFillbutton>DownunderHometabtofilltheformuladownafterselectingthecellsyouwanttofilloryoucanuseFillbutton>SeriesandthenselectAutofillandclickoktocopytheformulatillthereisabreakinthedata.
OrelseyoucanusetheshortcutCtrl+Dtofilldowntheformula.FirstyouhavetoselectthecellwiththeformulaalongwiththeothercellsyouwanttocopydownandpressCtrl+Dtocopytheformuladown.
UsingcalculationoperatorsinformulasOperatorsspecifythetypeofcalculationthatyouwanttoperformontheelementsofaformula.Thereisadefaultorderinwhichcalculationsoccur(thisfollowsgeneralmathematicalrules),butyoucanchangethisorderbyusingparentheses.
TYPESOFOPERATORSTherearefourdifferenttypesofcalculationoperators:Arithmetic,Comparison,Textconcatenation,andReference.
Arithmeticoperators
+(plussign)isusedforAddition,forexampleslike10+15.
–(minussign)isusedforSubtraction,forexamples10-2.
Negationisused,forexamples-6.
*(asterisk)isuseforMultiplication,forexamples4*8.
/(forwardslash)isusedforDivision,forexamples25/9
%(percentsign)isusedforPercent,forexamples25%
^(caret)isuseforExponentiation,forexamples6^2.
Comparisonoperators
YoucancomparetwovaluesbyusingtheoperatorsgivenbelowandtheresultwillalwaysbealogicalvalueTRUEorFALSE.
=(equalsign)meaningEqualto,ForexampleA1=C1.
>(greaterthansign)meaningGreaterthan,ForexampleA1>B1.
<(lessthansign)meaningLessthan,ForexampleD1<B1.
>=(greaterthanorequaltosign)meaningGreaterthanorequalto,ForexampleA1>=B1.
<=(lessthanorequaltosign)meaningLessthanorequalto,ForexampleA1<=B1.
<>(notequaltosign)meaningNotequalto,ForexampleA1<>B1.
Textconcatenationoperator
Usetheampersand(&)toconcatenate(join)oneormoretextstringstoproduceasinglepieceoftext.
Forexample“East”&“west”willgiveyou“Eastwest”.
Referenceoperators
Combinerangesofcellsforcalculationswiththefollowingoperators.
:(colon)istheRangeoperator,whichproducesonereferencetoallthecellsbetweentworeferences,includingthetworeferencesA5:C15
,(comma)istheUnionoperator,whichcombinesmultiplereferencesintoonereference.ForexampleSUM(A5:B15,G5:E15)
(space)Intersectionoperator,whichproducesonereferencetocellscommontothetworeferencesB7:D7C6:C8.
EXCELCALCULATIONORDERInsomecases,theorderinwhichacalculationisperformedcanaffectthereturnvalueoftheformula,soit’simportanttounderstandhowtheorderisdeterminedandhowyoucanchangetheordertoobtaintheresultsyouwant.
Ifyoucombineseveraloperatorsinasingleformula,Excelperformstheoperationsintheordershownbelow.Ifaformulacontainsoperatorswiththesameprecedence;sayforexamplebothamultiplicationanddivisionoperator,Excelevaluatestheoperatorsfromlefttoright.
Operators
:(colon)
(singlespace)
,(comma)
–Negation(asin–3)
%Percent
^Exponentiation
*and/Multiplicationanddivision
+and–Additionandsubtraction
&Connectstwostringsoftext(concatenation)
=
<>
<=
>=
<>
IfyouwanttochangetheaboveorderyoucanenclosethatparticularformulasectioninparenthesessothatExcelwillbeforcedtocalculatewhatevermentionedintheparenthesesfirst.
Forexampleifyouenterthisformula=5+4*6youwillgettheanswer29becausefirstitwillmultiplyandthenitwilladdaspertheoperatorprecedencementionedabove.Ifyou
wanttofirstaddandthenmultiplythenyoucanchangetheformulabyaddingtheparentheseslikethis=(5+4)*6.
CommonmistakeswhilecapturingFormulas.OPENANDCLOSINGPARENTHESES(BRACKETS)
Intheformulawhateverparentheses(brackets)youhaveopenedshouldbeclosed.ForexampleifyouenteraSUMformulalikethis=SUM(A1:A6)youcanseethereisanopeningandclosingparentheses.Ifyounesttheformulathentherewillbemoreopeningandclosingbracketsforeachformulas.
Excelautomaticallygiveseparatecolortoeachpairsofparentheses.
COLONTOINDICATEARANGE
Youshouldusethecolon(:)forreferringtoarangelikeA1:A10.Noothercharactersareallowed.
REQUIREDARGUMENTSSHOULDBEENTERED
Alltherequiredargumentsinaformulashouldbeenteredandtheargumentsmarkedinsquarebracketscanbeavoidedasperyourrequirement.
ForexampleinthisformulaVLOOKUP(lookup_value,table_array,col_index-num,[range_lookup])firstthreeargumentsorparametershastobesuppliedandthelastonerange_lookupisoptionalwhichyoucanprovideasperyourrequirementoryoudon’twanttogive.
NESTINGOFFUNCTIONS
Ifyouarenestingorclubbingtogetherotherfunctionsasargumentsthenyoucannestupto64levelsofnestedfunctioninaformula,nomorethanthat.
ENCLOSEOTHERSHEETNAMESINSINGLEQUOTATIONMARKS
Ifyourefertovaluesorcellsinanotherworksheetorworkbookinaformula,andthenameofthatworkbookorworksheetcontainsanon-alphabeticalcharacter,enclosethenamewithinsinglequotationmarks(‘).
INCLUDETHEPATHTOEXTERNALWORKBOOKS
Makesurethateachexternalreferenceyouenterinaformulacontainsaworkbooknameandthepathtotheworkbook.
ENTERNUMBERSWITHOUTFORMATTING
Makesurethatyoudon’tincludethenumberformatswhilecapturingnumbersinaformula.Ifyouputadollarsigninsideaformulabeforeacellreferencethecellreferencewillchangetoabsolutereferenceasdollarsigns($)areusedtoindicateabsolutereferences.
DON’TENCLOSENUMBERSINDOUBLEQUOTES
Youshouldnotenclosethenumbersindoublequoteswhenyousupplytheargumentstotheformula.Onlytextargumentsshouldbesuppliedindoublequotes.
EXCELFORMULASNOTUPDATINGAUTOMATICALLY
IftheExcelformulasarenotupdatingautomaticallythencheckwhethertheFormulacalculationissettomanualunderFormulastab>Calculationoptions.Ifitismanualyoucanchangethesametoautomatic.
HowtoforceExcelFormulastorecalculate?Ifforsomereason,youneedtohavetheCalculationoptionsettoManual,youcanforcetheformulastorecalculatebyclickingtheCalculatebuttonontheribbonorbyusingoneofthefollowingshortcuts:
Torecalculatetheentireworkbook:
PressF9,or
ClicktheCalculateNowbuttonontheFormulastab>Calculationgroup.
Torecalculateanactivesheet:
PressShift+F9,or
ClickCalculateSheetontheFormulastab.
Torecalculateallsheetsinallopenworkbooks:
PressCtrl+Alt+F9.
Andifyouwanttorecheckdependentformulasandthenrecalculatealltheformulasinallopenworkbooks.
PressCTRL+SHIFT+ALT+F9.
Ifyouneedtorecalculateonlyoneformulaonasheet,selecttheformulacell,entertheeditingmodeeitherbypressingF2ordoubleclickingthecell,andthenpresstheEnterkey.
FormulaerrorsinExcel.IfExcelcannotproperlyevaluateaworksheetformulaorfunction;itwilldisplayanerrorvaluesuchas#REF!,#NULL!,#DIV/0!-inthecellwheretheformulaislocated.
#NAME?Error
Thesearethesomeinstanceswherethiserrorwilloccur.
ifyoureferaformulathatdoesn’texistlikeinsteadofSUMyouuseSUMS
misspelledreference
textenteredwithoutenclosingdoublequotationmarks
rangedefinedwithoutcolon(:)thiserrorwilloccur.
#REF!Error
UsuallyiIfyoudeleteacellorcellrangewhichisusedforcalculatingaformulathiserrorwilloccur.SayifyouareaddingupthecellsA1andB1andifyoudeletetheBcolumnthiserrorwilloccur.
#DIV/0!ERROR
Dividedbyzeroproducesaninfinity.EXCELdoesthisbyproducing#DIV/0!error.
#N/AERROR
Thiserrormeansnotavailable,thedataisnotavailable.Givenbelowissomeinstanceswherethiserroroccurs.
WhileusingtheLookupfunctions(HLOOKUP,LOOKUP,MATCH,orVLOOKUP)ifthevalueyouaresearchingisnottherethenthiserrorwilloccur.
Ifanyrequiredargumentsisomittedfromabuilt-inorcustomworksheetfunctionthiserrorwilloccur.
#NULL!ERROR
Thistypeoferroroccursusuallyoccurswhentwoormorecellreferencesareseparatedincorrectlyorunintentionallybyaspaceinaformula.Likeinsteadofcoma=SUM(D1:D3E1:E3)youhaveusedspacetoseparatethesetworanges.
#NUM!ERROR
Generally#NUM!erroroccurswhenyourformulareturnsavaluebiggerthanwhatexcelcanrepresentorwrongdatatypemightbesuppliedinafunctionthatrequiresanumericargument.
#VALUE!ERROR
Thiserroroccurswhenthevariablesspecifiedtoafunctionareofwrongtypes.
OrifyouusethemathematicalformulalikeSUMwhichtakeinputasanumberbutcharsorstringsarebeingpassedtoit.
######ERROR
ThiserroroccurswhenyourEXCELcolumnisnotwideenoughtoaccommodatealargevalue.Forexample,ifalongnumberlike123123456456789789issettooccupyasmallcellthenitwouldshowupas####error.
Wideningthecellincaneradicatetheerrorinabovecasebuttherearefewmorescenarioswherethiserrorcanappear:
Theresultofyourformulaistoowidetofitinthecell.
Ifanegativenumberhasbeenformattedtodateortimethenitwillalsoproducethiserror.Thereasonbeingdateandtimearealwayssupposedtobepositive.
CIRCULARREFERENCEERROR
Thiserrorisrarestofalltheerrorstooccur.Thisbasicallyoccurswhenyoudefinearesultonacell,whichisalsoapartofoneofyourformula.ForexampleifyouaddvaluesfromrangeA2toA6withitstotalatcellA7.
ButwhatifIspecifytheresultatcellA6insteadofA7.A6beingpartofSUMrangeitself.Thenwewillgetintocircularreferencesandthiserrormightleadtowrongresults.
Thebestwaytoovercomethistoassigntheresultstoadifferentcellandtrytokeepvaluesandresultsasdifferentaspossible.
DebuggingFormulasIfyouwanttodebugtheformulathenyoucanusetheEvaluateformulaundertheFormulastab.SelectthecellhavingtheformulaandclickonEvaluateformulasforyoutoseethestepbystepcalculationoftheformula.
AlsoyoucanusetheTracePrecedentsandTraceDependentsundertheFormulatabtofindtheprecedentanddependentcells.
HowtouseThisBookAlthoughIwritethisbookwiththeintentiontoreadthisbookcovertocover,youcanreadthisbookfrommiddleorend,whateverwayyouwant.EveryFormulaisself-explanatorysoyoucanjumptoanypageyoulike.
FortheeaseofpracticingIhavemadeexamplefileswhichyoucandownloadfrommysiteExceltovba.com.Sobeforereadingthebookdownloadtheexamplefilesothatyoucanpracticewhileyouread.
Myrequesttoeachreadersistogothroughalltheexamplefilessothatyoucanlearnveryfast.Themoreyouunderstandtheexamplesthemoreexperienceyougainandthemoreyoucanimplementtheformulasinyourdaytodaywork.
Passwordisgivenattheendofthisbook.
Thanksagainfordownloadingthisbook.
1.Compatibility1.1MODETheMODEfunctionreturnsthemostcommonvalueorthemostfrequentlyoccurringnumbersinagroup.Forexample,=MODE(1,2,2,3,3,3,3,34,4,5,5,5,6)returns3.
Syntax:
=MODE(number1,[number2],…)
Parameterlist:
number1–anumberorcellreferencethatreferstonumericvalues.
number2-[optional]anumberorcellreferencethatreferstonumericvalues.
Numberscanbesuppliedasnumbersliketheaboveexampleorrangeslike=MODE(A1:A11,B4:B10)ornamedranges,orcellreferencesthatcontainnumericvalues.Upto255numberscanbesupplied.
Ifthesetofsuppliednumbersdoesnotcontainanyduplicates,MODEwillreturn#N/Aerror.
Pointstonote.
MODEisnowclassifiedasa“compatibilityfunction”.MicrosoftrecommendsthatMODE.SNGLorMODE.MULTIbeusedinstead.
1.2.RANKThisfunctionreturnstherank,thenumberindicatingtherankfromalistofnumbersinascendingordescendingorder.UseRANKwhenyouwanttoprovidearankforitemsinalist,butyoudon’twanttosortthelist.
Syntax:
=RANK(number,ref,[order])
Parameterlist:
number-thenumberwhoserankyouwanttofind.
ref-anarrayof,orareferenceto,alistofnumbersagainstyouwanttofindtheRank.Nonnumericvaluesinrefareignored.
order-[optional]whethertorankinascendingordescendingorder.Defaultorderorifomitteditis0=descendingorder,1isascendingorder.
Checktheexamplefileexceltovba.com-RANK.xls
InthisexampleJenuhasscoredhighestmarkinthelotsohewillgetRank1andRoywillgetRank2asheisthesecondhighestfollowedbyRamboRank3,JohnRank4,KevinRank5andMelvinRank6.ItmeanstherankwillbesortedintheDescendingorder(ColumnC)highermarkswillhavehigherrank.
Ifyouenterthethirdparameter1youcanseetheRankwillbesortedinreverse,inascendingorder.ItmeansRank1willbeMelvinashehasscoredthelowestmarksinthelotandKevinRank2followedbyJohn,Rambo,RoyandJenu.
Pointstonote.
Thisfunctionhasbeenreplacedwithnewfunctionsthatprovideimprovedaccuracyandwhosenamesbetterreflecttheirusage.ThenewfunctionsareRANK.AVGandRANK.EQ(newversionofRANKfunction).
AsthenamesuggestRANK.AVGwillprovideyoutherankandifmorethanonevaluehasthesamerank,theaveragerankisreturned.
AlthoughRANKfunctionisstillavailableforbackwardcompatibility,youshouldconsiderusingthenewfunctionsfromnowon,becausethisfunctionmaynotbeavailableinfutureversionsofExcel.
2.DateandtimeAboutDatesinEXCEL
Bydefault,MicrosoftExcelforWindowsusesthe1900datesystem.Excelisstoringthedatesasserialnumbersstartingfrom01/01/1900meansthefirstdayofJan1900istheday1and2ndJan1900isday2andJanuary1,2008isserialnumber39448becauseitis39447daysafterJanuary1,1900.MicrosoftExcelfortheMacintoshusesthe1904datesystem,soinMacintoshthedatestartsonJanuary1,1904sotheserialnumber1meansitisJanuary1,1904.
IfyouwanttoseetheserialnumberofanydatejustchangetheNumberformatofthatcelltoGeneralformat.
2.1.DATEThisfunctionwillcreateavaliddatefromthevaluesyousupplyasYear,MonthandDay.ReturnvaluewillbeserialnumberrepresentsaparticulardateinExcel(ifyouchangethedateformattogeneralyoucanseetheserialnumber).
Syntax:
=DATE(year,month,day)
Parameterlist:
year-theyeartousewhencreatingthedate.
month-themonthtousewhencreatingthedate.
day-thedaytousewhencreatingthedate.
Checktheexamplefileexceltovba.com-DATE.xls
InthisexampleyoucanseethedateisbeencreatedinDcolumnfromthethreeparametersyousupplyasYear(Acolumn),Month(Bcolumn)andDay(Ccolumn).
2.2.DATEVALUEThisfunctionwillconvertadateintextformattoavaliddateandreturnsaserialnumberthatrepresentsaparticulardateinExcel.
Syntax:
=DATEVALUE(date_text)
Parameterlist:
date_text-avaliddateintextformat.Ifdate_textisacelladdress,valueofthecellmustbetext.Ifdate_textisentereddirectlyintotheformulaitmustbeenclosedinquotes.
Checktheexamplefileexceltovba.com-DATEVALUE.xlsx
Youcanseeinthelastcalculationwehaveusedthe&charactertojoinallthedatesastextinordertogivetheargumentastext.
Excelisstoringthedatesasserialnumbersstartingfrom01/01/1900meansthefirstdayofJan1900isthedayoneand2ndJan1900isday2likethat.Soifyouwanttogettheserialnumberofadateenteredastextyoucanusethisfunction.
Pointstonote.
Willreturna#VALUEerrorifdate_textreferstoacellthatdoesnotcontainadateformattedastext.
2.3.DAYThisfunctionwillreturnthedayasnumber(1–31)fromaDateandthereturnvaluewillbeanyofthenumberfrom1to31.
Syntax:
=DAY(serial_number)
Parameterlist:
serial_number-avalidExceldateinserialnumberformat.
Checktheexamplefileexceltovba.com-DATEVALUE.xlsx
InthisexampleonlytheDaypartisbeenpickedfromthedate.
2.4.DAYSThisfunctionreturnsthenumberofdaysbetweentwodates.ThisfunctionisavailablefromExcel2013andExcelforMac2011.
Syntax:
=DAYS(end_date,start_date)
Parameterlist:
end_date-theenddate.
start_date-thestartdate.
Checktheexamplefileexceltovba.com-DAYS.xlsx
Inthisexamplewehavecalculatedthenumberofdaysbetweentwodates.Youcanseewearegettingthe#NUMvalueerrorwhentherangefallsoutsideand#VALUEerrorwhenwetrytocomparethedateandtext.
PointstoNote.
Ifeitheroneofthedateargumentsistext,thatargumentwillbetreatedasDATEVALUE(date_text)andreturnsanintegerdate.
Ifdateargumentsarenumericvaluesthatfalloutsidetherangeofvaliddates,DAYSreturnsthe#NUM!errorvalue.
Ifdateargumentsarestringsthatcannotbetreatedasvaliddates,DAYSreturnsthe#VALUE!errorvalue.
Ifyouwanttodirectlyenterthedateslikethis=DAYS(“22/05/2015”,“20/05/2015”)then
youmustenclosethedatesinquotationmarks.
2.5.DAYS360Thisfunctioncalculatesthenumberofdaysbetweentwodates,basedona360-dayyear(twelve30-daymonths)whichisusedinsomeaccountingcalculations.Usethisfunctiontohelpcomputepaymentsandreceiptsifyouraccountingsystemisbasedontwelve30-daymonths.
Syntax:
=DAYS360(start_date,end_date,[method])
Parameterlist:
start_date-thestartdate.DatesshouldbeenteredbyusingtheDATEfunction,orderivedfromtheresultsofotherformulasorfunctions.
end_date-theenddate.
method-[optional]thetypeofdaycountbasistouse.FALSE(default)oromittedisUSmethod,TRUEisEuropeanmethod.
FALSE(default)oromitted-USmethod-Ifthestartingdateisthelastdayofamonth,itbecomesequaltothe30thdayofthesamemonth.Whentheenddateisthelastdayofthemonth,andthestartdateislessthan30days,theenddateissettothe1stofthenextmonth,otherwisetheenddateissettothe30thofthesamemonth.
TRUE-Europeanmethod.Startingdatesandendingdatesequaltothe31stofamontharesettothe30thofthesamemonth.
Checktheexamplefileexceltovba.com-DAYS360.xlsx
2.6.EDATEThisfunctionreturnsthesamedateinfutureorpastmonthsandreturnstheserialnumberofthedate.UseEDATEtocalculatematuritydatesorduedatesthatfallonthesamedayofthemonthasthedateofissue.
Syntax:
=EDATE(start_date,months)
Parameterlist:
start_date-adatethatrepresentsthestartdateinavalidExcelserialnumberformat.
months-thenumberofmonthsbeforeorafterstart_date.Apositivevaluetogetafuturedateandnegativevalueforthepastdate.
PointstoNote.
Ifstart_dateisnotavaliddate,EDATEreturnsthe#VALUE!errorvalue.
Ifmonthenteredisnotanintegeritistruncated.
2.7.HOURThisfunctionwillreturnthehourasanumber(0-23)fromatimeandreturnsanumberrangingfrom0(12.00AM)to23(11:00PM).
Syntax:
=HOUR(serial_number)
Parameterlist:
serial_number-avalidtimeinaformatExcelrecognizes.Timemaybeenteredastextstringswithinquotationmarks(forexample,“9:35PM”),asdecimalnumbers(forexample,0.78125,whichrepresents6:45PM),orasresultsofotherformulasorfunctions(forexample,TIMEVALUE(“9:35PM”)).
Checktheexamplefileexceltovba.com-HOUR.xlsx
Excelstoresdatesandtimesasserialnumbers.Forexample,thedateJan1,200012:00PMisequaltotheserialnumber32526.5inExcel.TocheckthatExceliscorrectlyrecognizingadateortime,youcantemporarilyformatthedateasanumber.
2.8.MINUTEThisfunctionwillgettheminuteasanumber(0-59)fromatimeandreturnsanumberbetween0and59.
Syntax:
=MINUTE(serial_number)
Parameterlist:
serial_number-avalidtimeinaformatExcelrecognizes.
Checktheexamplefileexceltovba.com-MINUTE.xls
Pointstonote.
Timescanbesuppliedastext(e.g.“7:45PM”)orasdecimalnumbers(e.g.0.5,whichequals12:00PM).
Excelstoresdatesandtimesasserialnumbers.Forexample,thedateJan1,200012:00PMisequaltotheserialnumber32526.5inExcel.TocheckthatExceliscorrectlyrecognizingadateortime,youcantemporarilyformatthedateasanumber.
2.9.MONTHThisfunctionwillprocurethemonthasanumber(1-12)fromadateandreturnsanumberbetween1and12.
Syntax:
=MONTH(date)
Parameterlist:
date-avaliddateinaformatExcelrecognizes.
Checktheexamplefileexceltovba.com-MONTH.xlsx
InthisexamplewehaveextractedmonthusingMONTHfunctionfromvariousdateformats.
2.10.NETWORKDAYS
Thisfunctionreturnsanumberrepresentingfullworkingdaysbetweenstart_dateandend_date.Workingdaysexcludeweekends(bydefaultSaturdayandSunday)andanydatesyousupplyasholidays.
Youcanusethisfunctiontocalculatethebenefitsoftheemployeesthataccumulateonthebasisofnumberofdaysworkedduringaspecificterm.
Syntax:
=NETWORKDAYS(start_date,end_date,[holidays])
Parameterlist:
start_date-thestartdate.
end_date-theenddate.
holidays-[optional]alistofoneormoredatesthatshouldbeconsideredasholidays.
Checktheexamplefileexceltovba.com-NETWORKDAYS.xlsx
InthisexampleforfirstthreecaseswearejustcalculatingNETWORKDAYSwithoutgivingthethirdparametersothatitwilleliminateonlytheweekends(bydefaultSaturdayandSunday)andinthefourthcasewearegivingthetwodatesasholidayssothisfunctionwillexcludethesetwoholidaysandtheweekendinbetweenthesedays.
IfyouwanttomakeanyotherdaysasweekendthenyoushouldusetheNETWORKDAYS.INTLfunction.
Pointstonote.
Ifanyargumentisnotavaliddate,NETWORKDAYSreturnsthe#VALUE!errorvalue.
2.11.NETWORKDAYS.INTL
Thisfunctionwillcalculatetheworkingdaysbetweentwodatesexcludingweekends(bydefaultSaturdayandSunday)andreturnsthenumberofdays.ThisfunctionismoreversatilethantheNETWORKDAYSfunctionbecauseitallowsyoutocontrolwhichdayordaysoftheweekareconsideredweekends,youcanmakeanyoftheday(likeMondayorTuesday)oranyofthetwodays(likeTuesdayandWednesdayorWednesdayandThursday)asweekend.
Alsoyoucanspecifyholidaysasfourthparametersothatholidayswillnotbecountedalongwithweekendwhilecalculatingthenumberofdays.ThisfunctionwasintroducedinExcel2010.
Syntax:
=NETWORKDAYS.INTL(start_date,end_date,[weekend],[holidays])
Parameterlist:
start_date-thestartdate.
end_date-theenddate.
weekend-[optional]settingforwhichdaysoftheweekshouldbeconsideredweekends.
holidays-[optional]areferencetodatesthatshouldbeconsiderednon-workdays.
Checktheexamplefileexceltovba.com-NETWORKDAYS.INTL.xlsx
Theweekendnumbers(fourthparameter)arelistedbelow.
Weekendnumber––—Weekenddays
1oromitted)––––—Saturday,Sunday
2––––––––––Sunday,Monday
3––––––––––Monday,Tuesday
4––––––––––Tuesday,Wednesday
5––––––––––Wednesday,Thursday
6––––––––––Thursday,Friday
7––––––––––Friday,Saturday
11–––––––––—Sundayonly
12–––––––––—Mondayonly
13–––––––––—Tuesdayonly
14–––––––––—Wednesdayonly
15–––––––––—Thursdayonly
16–––––––––—Fridayonly
17–––––––––—Saturdayonly
PointstoNote.
Ifstart_dateisgreaterthanend_date,thefunctionreturnsanegativevalue.
Ifstart_dateorend_dateisoutofrange,NETWORKDAYS.INTLreturnsthe#NUM!error.
Ifweekendisinvalid,NETWORKDAYS.INTLreturnsthe#VALUE!error.
2.12.NOWThisfunctionwillreturnstheserialnumberofthecurrentdateandtime.
Syntax:
=NOW()
NOWtakesnoparametersbutrequiresemptyparentheses.ThevaluereturnedbyNOWwillcontinuallyupdateeachtimetheworksheetisrefreshed(forexample,eachtimeavalueisenteredorchanged).
UseF9toforcetheworksheettorecalculateandupdatethevalue.
Checktheexamplefileexceltovba.com-NOW.xls
Intheaboveexampleyoucanseethefirstformulawillreturncurrentdateandtimeandthesecondformulawillreturnlastweek’sdateandtimeifyouputa-7aftertheformula.Thirdformulawillgetnextweek’sdateandtimeifyouput+7aftertheformula.
Likewiseyoucanaddorsubtractdatesfromnowtogetthedatesyouwant.
2.13.SECONDThisfunctionreturnstheSecondasanumber(0-59)fromaTimeandreturnsanumberbetween0and59.
Syntax:
=SECOND(serial_number)
Parameterlist:
serial_number-avalidtimeinaformatExcelrecognizes.
Checktheexamplefileexceltovba.com-SECOND.xlsx
Timescanbesuppliedastext(e.g.“7:45PM”)orasdecimalnumbers(e.g.0.5,whichequals12:00PM).
Excelstoresdatesandtimesasserialnumbers.Forexample,thedateJan1,200012:00PMisequaltotheserialnumber32526.5inExcel.TocheckthatExceliscorrectlyrecognizingadateortime,youcantemporarilyformatthedateasanumber.
2.14.TIMEThisfunctioncreatesatimewithhours,minutes,andsecondsyouprovideandreturnsadecimalnumberrepresentingaparticulartimeinExcel.Useittocreateavalidtimewhenyouhave(orcansupply)thesecomponentvaluesseparately.Onceyouhaveavalidtime,youcanformatitanywayyoulike.
Syntax:
=TIME(hour,minute,second)
Parameterlist:
hour-thehourforthetimeyouwishtocreate.
minute-theminuteforthetimeyouwishtocreate.
second-thesecondforthetimeyouwishtocreate.
Checktheexamplefileexceltovba.com-TIME.xlsx
ThedecimalnumberreturnedbyTIMEisavaluerangingfrom0(zero)to0.99988426,representingthetimesfrom0:00:00(12:00:00AM)to23:59:59(11:59:59P.M.).
2.15.TIMEVALUEThisfunctionreturnsthedecimalnumberofthetimerepresentedbyatextstring.Thedecimalnumberisavaluerangingfrom0(zero)to0.99988426,representingthetimesfrom0:00:00(12:00:00AM)to23:59:59(11:59:59P.M.).
Syntax:
=TIMEVALUE(time_text)
Parameterlist:
time_text-atextstringthatrepresentsatimeinanyoneoftheMicrosoftExceltimeformats;forexample,“6:45PM”and“18:45”textstringswithinquotationmarksthatrepresenttime.
FormulaDescriptionResult
=TIMEVALUE(“8:24AM”)Decimalpartofaday,withonlythetimespecified0.35
=TIMEVALUE(“22-Aug-20119:35AM”)Decimalpartofaday,withdateandtimespecified0.399305556
2.16.TODAYThisfunctionreturnsthecurrentdate.(aserialnumberrepresentingtheparticulardateinExcel).
Syntax:
=TODAY()
Thisfunctionhasnoparametersbutrequiresemptyparentheses.Thisfunctioncanbeusedtofindouttheageofapersoninyearslikethis.=YEAR(TODAY())-1980.ThisformulausesTODAYfunctionasanargumentintheYEARfunctiontogetthecurrentyearandthensubtract1980togetthedifferenceinyears.
=TODAY()functionreturnsthecurrentdate.
=TODAY()+7willreturnthecurrentdateplus7days.
2.17.WEEKDAYThisfunctionreturnsthedayoftheweekasanumberbetween1(Sunday)and7(Saturday)bydefault.AndifyouwanttochangetheStartingdayfromSundaytoMondayoranyotherdayyoucanusethereturntypeoption.
Syntax:
=WEEKDAY(serial_number,[return_type])
Parameterlist:
serial_number-thedateforwhichyouwanttogetthedayofweek.
return_type-[optional]anumber1-3and11-17(return_typedetailsgivenbelow)representingstartingdayoftheweek.Defaultis1,Sunday(1stday)toSaturday(7thday).
return_type–—Numberreturned
1oromitted–—Numbers1(Sunday)through7(Saturday)
2––––––-Numbers1(Monday)through7(Sunday)
3––––––-Numbers0(Monday)through6(Sunday)
11––––––Numbers1(Monday)through7(Sunday)
12––––––Numbers1(Tuesday)through7(Monday)
13––––––Numbers1(Wednesday)through7(Tuesday)
14––––––Numbers1(Thursday)through7(Wednesday)
15––––––Numbers1(Friday)through7(Thursday)
16––––––Numbers1(Saturday)through7(Friday)
17––––––Numbers1(Sunday)through7(Saturday)
Checktheexamplefileexceltovba.com-WEEKDAY.xlsx
Inthisexampleyoucanseethealltheoptionswillgiveadaynumberfrom1to7exceptifyouusethereturn_type3whichstartsthedayon0(Monday)andendson6(Sunday).
2.18.WEEKNUMThisfunctionreturnstheweeknumberforagivendateandreturnsanumberbetween1and54.
Therearetwosystemsforthisfunction:
System1-weekcontainingJanuary1asthefirstweekoftheyear,andisnumberedweek1.
System2-weekcontainingthefirstThursdayoftheyearasthefirstweekoftheyear,andisnumberedasweek1(commonlyknownastheEuropeanweeknumberingsystem).
Syntax:
=WEEKNUM(serial_num,[return_type])
Parameterlist:
serial_num-avalidExceldateinserialnumberformat.
return_type-[optional]thedaytheweekbegins.Defaultis1.
return_type–-Weekbeginson–System
1oromitted–-Sunday––––––1
2––––––-Monday–––––-1
11––––––Monday–––––-1
12––––––Tuesday–––––-1
13––––––Wednesday––––1
14––––––Thursday–––––1
15––––––Friday––––––-1
16––––––Saturday–––––-1
17––––––Sunday––––––1
21––––––Monday–––––—2
Checktheexamplefileexceltovba.com-WEEKNUM.xlsx
InthisexampleyoucanseethealltheoptionsareusingtheSystem1exceptthelastonewhichisusingtheSystem2inwhichtheweekcontainingthefirstThursdayoftheyearisthefirstweekoftheyear.Sointhiscase01Jan2016isFridaysoitwillnotbecountedasthefirstweek,04thJan2016willbethefirstweekasithasthefirstThursdayoftheyear.
2.19.WORKDAYThisfunctionreturnsadateaccordingtothenumberofworkingdaysyouspecifybeforeorafteradate(thestartingdate).Useapositivenumberfordaystocalculatefuturedates,andanegativenumberforpastdates.Bydefault,WORKDAYwillexcludeweekends(SaturdayandSunday).
Forexample=WORKDAY(“01/01/2016”,3)willgiveyoutheresult42375whichistheserialnumberofthedate06-01-16.1stJanisFriday,4thJanisMondayand5thJanisTuesday,sinceyouhavegiventhesecondparameteras3youwillgetthefourthworkdaydateasanswerwhichis06Jan2016.
Syntax:
=WORKDAY(start_date,days,[holidays])
Parameterlist:
start_date-thedatefromwhichtostart.
days-Theworkingdaysbeforeorafterstart_date.
holidays-[optional]Alistdatesthatshouldbeconsiderednon-workdays.
Checktheexamplefileexceltovba.com-WORKDAY.xlsx
Inthisexampleforthefirstthreeweareonlycalculatingthedaysinthepastandpresentwithoutgivingthethirdparameterholidaysandinthelastonewehavegiventwodates(thirdparameter)asholidaystoexcludefromthecalculationofthefutureWorkdaydate.
InsomecountriestheWeekendswilldiffer.InthatcaseyoumustusetheWORKDAY.INTLfunctionasthisfunctioncansettheweekendtoFridayandSaturdayorMondayorSundayoranydayoranytwoconsecutivedaysofyourchoice.
2.20.WORKDAY.INTLThisfunctionreturnsadateinworkingdaysinfutureorpastfromthestartdateandno.ofdaysyouprovide.ThisfunctionissamelikeWORKDAYfunctionandtheonlydifferenceisyoucansettheweekendtoFridayandSaturdayorMondayorSundayoranydayoranytwoconsecutivedaysofyourchoice
Bydefault,WORKDAY.INTLwillexcludeweekends(SaturdayandSunday).WORKDAY.INTLcanalsooptionallytakeintoaccountholidays(fourthparameter).FortheHoliday’sargument,supplyarangethatcontainsholidaydateordateswhichwillbetreatedasnon-workingdaysandwillnotbeincludedintheresult.
Syntax:
=WORKDAY.INTL(start_date,days,[weekend],[holidays])
Parameterlist:
start_date-thestartdate.
days-theenddate.
weekend-[optional]settingforwhichdaysoftheweekshouldbeconsideredweekends(weekendnumbergivenbelow).
holidays-[optional]alistofoneormoredatesthatshouldbeconsiderednon-workdays.
weekend-number––—Weekenddays
1oromitted–––––Saturday,Sunday
2–––––––––—Sunday,Monday
3–––––––––—Monday,Tuesday
4–––––––––—Tuesday,Wednesday
5–––––––––—Wednesday,Thursday
6–––––––––—Thursday,Friday
7–––––––––—Friday,Saturday
11–––––––––-Sundayonly
12–––––––––-Mondayonly
13–––––––––-Tuesdayonly
14–––––––––-Wednesdayonly
15–––––––––-Thursdayonly
16–––––––––-Fridayonly
17–––––––––-Saturdayonly
Checktheexamplefileexceltovba.com-WORKDAY.INTLxlsx
InthisexampleinthelastcalculationwehavesuppliedtwoholidaydatesasfourthparametertoexcludethesedatesalongwiththeweekendSaturday.
Pointstonote.
Ifstart_dateorstart_date+dayorholidayisinvalid,WORKDAY.INTLreturnsthe#NUM!error.
Ifweekendisinvalid,WORKDAY.INTLreturnsthe#VALUE!error.
2.21.YEARThisfunctionreturnstheyearfromadate.Forexample=YEAR(01-01-00)willreturn1900and=YEAR(20-03-15)willreturn2015.
Syntax:
=YEAR(date)
Parameterlist:
date-adatefromwhichtoextracttheyear.
Excelonlyhandlesdatesafter1/1/1900soyoucanusethisfunctionfromthedatesstartingfrom1900.
3.Engineering3.1.CONVERTTheCONVERTfunctionconvertsanumberinonemeasurementsystemtoanother.Forexample,youcanuseCONVERTtoconvertfeetintometers,poundsintokilograms,gallonsintoliters,andformanyotherunitconversions.
Syntax:
=CONVERT(number,from_unit,to_unit)
Parameterlist:
number-thenumericvaluetoconvert.
from_unit-theunittoconvert.
to_unit–totheunityouwanttoconvert.
Checktheexamplefileexceltovba.com-CONVERT.xlsx
ShownbelowarethevariousunitsthatareavailabletotheCONVERTfunction.Inallcases,Unitcanbeusedforeitherfrom_unitorto_unit,itshouldmementionedinquotationmarks.
Weightandmass–––––––From_unitorto_unit
Gram–––––––––––––-“g”
Slug––––––––––––––“sg”
Poundmass(avoirdupois)––––“lbm”
U(atomicmassunit)––––––—“u”
Ouncemass(avoirdupois)––––-“ozm”
Grain–––––––––––––—“grain”
U.S.(short)hundredweight––––-“cwt”or“shweight”
Imperialhundredweight–––––—“uk_cwt”or“lcwt”(“hweight”)
Stone–––––––––––––—“stone”
Ton––––––––––––––—“ton”
Imperialton–––––––––––“uk_ton”or“LTON”(“brton”)
Distance––––––––From_unitorto_unit
Meter–––––––––––—“m”
Statutemile–––––––––-“mi”
Nauticalmile–––––––––“Nmi”
Inch–––––––––––––“in”
Foot–––––––––––––“ft”
Yard–––––––––––––“yd”
Angstrom––––––––––—“ang”
Ell––––––––––––––“ell”
Light-year––––––––––—“ly”
Parsec––––––––––––-“parsec”or“pc”
Pica(1/72inch)––––––––—“Picapt”or“Pica”
Pica(1/6inch)–––––––––-“pica”
U.Ssurveymile(statutemile)––—“survey_mi”
TimeFrom_unitorto_unit
Year“yr”
Day“day”or“d”
Hour“hr”
Minute“mn”or“min”
Second“sec”or“s”
PressureFrom_unitorto_unit
Pascal“Pa”(or“p”)
Atmosphere“atm”(or“at”)
mmofMercury“mmHg”
PSI“psi”
Torr“Torr”
ForceFrom_unitorto_unit
Newton“N”
Dyne“dyn”(or“dy”)
Poundforce“lbf”
Pond“pond”
Energy––––––––-From_unitorto_unit
Joule–––––––––––––“J”
Erg––––––––––––––“e”
Thermodynamiccalorie–––––“c”
ITcalorie–––––––––––-“cal”
Electronvolt––––––––––“eV”(or“ev”)
Horsepower-hour–––––––—“HPh”(or“hh”)
Watt-hour–––––––––––“Wh”(or“wh”)
Foot-pound–—––––––––—“flb”
BTU–––––––––––––—“BTU”(or“btu”)
Power––––––––––—From_unitorto_unit
Horsepower––––––––“HP”(or“h”)
Pferdestärke––––––––“PS”
Watt––––––––––-“W”(or“w”)
Magnetism––From_unitorto_unit
Tesla–––––––—“T”
Gauss–––––––-“ga”
Temperature––––-From_unitorto_unit
DegreeCelsius––––“C”(or“cel”)
DegreeFahrenheit––-“F”(or“fah”)
Kelvin––––––––“K”(or“kel”)
DegreesRankine–––-“Rank”
DegreesRéaumur–––“Reau”
Volume(orliquidmeasure)–-From_unitorto_unit
Teaspoon––––––––––––—“tsp”
Modernteaspoon–––––––––—“tspm”
Tablespoon–—––––––––––—“tbs”
Fluidounce––––––––––––—“oz”
Cup––––––––––––––––“cup”
U.S.pint––––––––––––––“pt”(or“us_pt”)
U.K.pint––––––––––––––“uk_pt”
Quart–––––––––––––––-“qt”
Imperialquart(U.K.)–––––––––-“uk_qt”
Gallon–––––––––––––––-“gal”
Imperialgallon(U.K.)–––––––––“uk_gal”
Liter––––––––––––––––-“l”or“L”(“lt”)
Cubicangstrom–––––––––––—“ang3”or“ang^3”
U.S.oilbarrel––––––––––––—“barrel”
U.S.bushel–––––––––––––—“bushel”
Cubicfeet––––––––––––––-“ft3”or“ft^3”
Cubicinch––––––––––––––-“in3”or“in^3”
Cubiclight-year––––––––––––“ly3”or“ly^3”
Cubicmeter–––––––––––––—“m3”or“m^3”
CubicMile––––––––––––––-“mi3”or“mi^3”
Cubicyard––––––––––––––—“yd3”or“yd^3”
Cubicnauticalmile–––––––––––“Nmi3”or“Nmi^3”
CubicPica–––––––––––––––“Picapt3”,“Picapt^3”,“Pica3”or“Pica^3”
GrossRegisteredTon––––––––––-“GRT”(“regton”)
Measurementton(freightton)––––––“MTON”
AreaFrom_unitorto_unit
Internationalacre––––––––“uk_acre”
U.S.survey/statuteacre–––––—“us_acre”
Squareangstrom––––––––—“ang2”or“ang^2”
Are–––––––––––––––“ar”
Squarefeet–––––––––––—“ft2”or“ft^2”
Hectare–––––––––––––-“ha”
Squareinches–––––––––––“in2”or“in^2”
Squarelight-year–––––––––—“ly2”or“ly^2”
Squaremeters––––––––––-“m2”or“m^2”
Morgen–––––––––––––—“Morgen”
Squaremiles––––––––––––“mi2”or“mi^2”
Squarenauticalmiles––––––––-“Nmi2”or“Nmi^2”
SquarePica––––––––––––—“Picapt2”,“Pica2”,“Pica^2”or“Picapt^2”
Squareyards––––––––––––-“yd2”or“yd^2”
Information–––-From_unitorto_unit
Bit–––––––––-“bit”
Byte––––––––—“byte”
Speed––––––—From_unitorto_unit
Admiraltyknot-––––-“admkn”
Knot–––––––––-“kn”
Metersperhour––––-“m/h”or“m/hr”
Meterspersecond–––-“m/s”or“m/sec”
Milesperhour––––—“mph”
Pointstonote.
Iftheinputdatatypesareincorrect,CONVERTreturnsthe#VALUE!errorvalue.
Iftheunitdoesnotexist,CONVERTreturnsthe#N/Aerrorvalue.
Iftheunitdoesnotsupportabinaryprefix,CONVERTreturnsthe#N/Aerrorvalue.
Iftheunitsareindifferentgroups,CONVERTreturnsthe#N/Aerrorvalue.
Unitnamesandprefixesarecase-sensitive.
4.Financial4.1.FVThisfunctioncalculatesthefuturevalueofaninvestmentassumingperiodicconstantpaymentswithaconstantinterestrate.
Syntax:
=FV(rate,nper,pmt,[pv],[type])
Parameterlist:
rate-theinterestrateperperiod.
nper-thetotalnumberofpaymentperiods.
pmt-thepaymentmadeeachperiod.Mustbeenteredasanegativenumberasthemoneyisgoingout.
pv-[optional]thepresentvalueoffuturepayments.Ifomitted,assumedtobezero.Mustbeenteredasanegativenumber.
type-[optional]whenpaymentsaredue.0=endofperiod,1=beginningofperiod.Defaultis0.
Checktheexamplefileexceltovba.com-FV.xlsx
InthisexamplewearecalculatingtheFuturevalueofaninvestment.Firstwearecalculatingthefuturevalueconsideringthepresentvalueinvestedandalsothepaymentisbeendoneatthebeginningoftheyear.
Secondonewearecalculatingthefuturevaluewithoutanyinitialinvestmentandthepaymentduewiththeendoftheperiod.
Andthirdwearecalculatingthefuturevaluewithoutanyinitialinvestmentandthepaymentisdueatthebeginningoftheperiod.
Pointstonote.
1.Unitsforrateandnpermustbeconsistent.Forexample,ifyoumakemonthlypaymentsonafive-yearloanat10percentannualinterest,use10%/12(annualrate/12=monthlyinterestrate)forrateand5*12(60paymentstotal)fornper.Ifyoumakeannualpaymentsonthesameloan,use10%(annualinterest)forrateand5(5paymentstotal)fornper.
2.Ifpmtisforcashout(i.edepositstosaving,etc),paymentvaluemustbenegative;forcashreceived(income,dividends),paymentvaluemustbepositive.
4.2.PMTThisfunctioncalculatestheperiodicpaymentforaloanbasedonconstantpaymentandconstantinterestrate.ForexampleifyouarebuyingaCarworth$20000with24monthsloanrepaymentand7percentinterestyoucancalculatethemonthlypaymentandhowmuchprincipalandinterestyouarepayingeachmonth.
Syntax:
=PMT(rate,pmt,pv,[fv],[type])
Parameterlist:
rate-theinterestratefortheloan,ifyouarepayingmonthlyyouhavetodivideby12.
pmt-thetotalnumberofpaymentsfortheloan(12monthsof36months).
pv-thepresentvalue,ortotalvalueofallloanpaymentsnow.
fv-[optional]thefuturevalue,oracashbalanceyouwantafterthelastpaymentismade.Defaultsto0(zero).
type-[optional]whenpaymentsaredue.0=endofperiod.1=beginningofperiod.Defaultis0.
Example1:CalculatingtheCarLoanrepaymentamount.
Checktheexamplefileexceltovba.com-PMT.xlsxSheet1
Inthisexamplefilewearecalculatinghowmuchwewillpayasprincipalandinterestforthecarloanforaperiodof48months.Carvalueis$10000andweareprocuringaloanat8percentforatermof48months.Formulaforthisis=PMT(B2/12,B3,B1).
Firstparameterwewillentertheinterestratesincewearepayingmonthlywewilldividetheinterestrateby12,8%/12togetthemonthlyinterestrate.
Secondweareenteringtheperiodinmonthshereitis48.
ThirdparameterweareenteringtheCarvalueorprincipalamountorloantaken,wehaveputanegativesigntoindicatetheamountisbeendebitedfromourbank.
Afterenteringtheformulayouwillgetthemonthlyamounttobepaidforthisloanfor48months.
YoucannowmultiplythePeriodwiththeMonthlypaymentstogetthetotalloanamountpaidwhichis$11,718.20andifyousubtractthisfromthePrincipalyouwillgettheinterestpaidforthisloanwhichis$1,718.20.
PointstoNote.
ThepaymentreturnedbyPMTincludesprincipalandinterestbutwillnotincludeanytaxes,fees,hiddencharges,reservepaymentsorfees.
Makesurethatthefirstandsecondparametersyousupplyshouldbecorrect.Forexampleifyouarecalculatingamonthlypaymentofaloanfor4years@10%,then10%/12willbetherateand4*12willbenper.Ifyoumakeannualpaymentforthesameloanthen10%willbetherateand4willbenper.
Ifitisquarterly,ratewillbe10%/4and16willbethenper(4yearsmultipliedby4quarter).
TheremaybeslightdifferenceintheamountcalculatedinExcel2007andExcel2010asalgorithmusedisdifferentinbothandExcel2010calculationismoreaccurate.
Example2:Calculatingtheamounttobesavedmonthlytoget75000attheendof10Years.
Checktheexamplefileexceltovba.com-PMT.xlsxSheet2
Herethegoalistobuildacorpusof75000attheendof10years.Sointheformulafirstparameterweareenteringtheinterestrateasmonthly,secondparameterweareenteringthetermfor10yearswhichis10years*12monthswhichis120,thirdparameterweareentering0becausethepresentvalueis0fromwhichwewanttobuilditto75000andthelastparameterwearesupplyingtheamountweshouldbuildwhichis75000.
4.3.IPMTThisfunctionreturnstheinterestpaymentforaninvestmentforagivenperiodwithaconstantpaymentandinterestrate.
Syntax:
IPMT(rate,per,nper,pv,[fv],[type])
Parameterlist:
Rate–theinterestrateperperiod.
Per-theperiodforwhichyouwanttofindtheinterestandmustbeintherange1tonper.
nper-thetotalnumberofpaymentperiodsinanannuity.
Pv-thepresentvalue,orthelump-sumamountthataseriesoffuturepaymentsisworthrightnow.
Fv-thefuturevalue,oracashbalanceyouwanttoattainafterthelastpaymentismade.Iffvisomitted,itisassumedtobe0(thefuturevalueofaloan,forexample,is0).
Type-thenumber0or1andindicateswhenpaymentsaredue.Iftypeisomitted,itisassumedtobe0.0=attheendoftheperiod,1=atthebeginningoftheperiod.
Checktheexamplefileexceltovba.com-IPMT.xlsx
InthisexamplewearecalculatingtheinterestamountforfirstmonthinthecellB9usingtheformula=IPMT(B3/12,B6,B4*12,B2).Sincewearepayingmonthlywearecalculatingthemonthlyratebydividingitby12,secondparameterwearesupplyingthemonthnumber,firstmonth,fromthetotaltermof36months.Thirdparameterweareprovidingthetotalperiodbymultiplyingthemonthwithyearstoarriveat36andthefourthparameteristheloanamountitself.
LikethatthesecondmonthiscalculatedinthecellB10.
AndincellB11wearecalculatingtheinterestdueinthelastyear(3rdyear),hereweareconsideringtheinterestrateannuallysononeedtodivideby12andperandNperare
samebecausewearefindingtheinterestforthelastyearwhichis3soperwillbe3andNperis3becausewearepayingonlythreetimesintheloanperiod.
PointstoNote.
Makesurethatthefirstandsecondparametersyousupplyshouldbecorrect.Forexampleifyouarecalculatingamonthlypaymentofaloanfor4years@10%,then10%/12willbetherateand4*12willbenper.Ifyoumakeannualpaymentforthesameloanthen10%willbetherateand4willbenper.
Ifitisquarterly,ratewillbe10%/4and16willbethenper(4yearsmultipliedby4quarter).
4.4.PVThisfunctioncalculatesthepresentvalueofaloanorinvestmentbasedonconstantinterestrate.
Syntax:
=PV(rate,nper,pmt,[fv],[type])
Parameterlist:
rate-theinterestrateperperiod.Ifitis10%annualrateandmakesmonthlypaymentthenitis10%/12.
nper-totalnumberofpaymentperiods.Ifitisatwoyearloanthen2*12,24periods.
pmt-thepaymentmadeforeachperiod.Ifpmtisomitted,youmustincludethefvargument.
fv–[Optional]thecashbalanceyouwanttoattainafterthelastpaymentismade.Iffvisomittedcashpaymentwillbe0attheendoftheloan.Iffvisomitted,youmustincludethepmtargument.
type-[Optional].whenwillbepaymentdue,0oromitted=endoftheperiodand1=beginningoftheperiod
Checktheexamplefileexceltovba.com-PV.xlsx
InthisexamplewearecalculatingtheLoanamount.Paymentamountisthemonthlypaymentamountincludingprincipalandinterest(-negativesigntoindicatethecashisleavingyourbank),interestrateis8%whichwearedividingby12togetthemonthlyinterestrateandperiodis48(12monthsx4).
Ifyouarepayingquarterly,ratewillbe8%/4and16(4periodx4years)willbethenper.
4.5.NPERThisfunctionreturnsthenumberofperiodsforaninvestmentbasedonconstantperiodicpaymentsandinterestrate.
Syntax:
=NPER(rate,pmt,pv,[fv],[type])
Parameterlist:
rate-theinterestrateperperiod.
pmt-thepaymentmadeeachperiod.
pv-thepresentvalue,ortotalvalueofallpaymentsnow.
fv-[optional]thefuturevalue,oracashbalanceyouwantafterthelastpaymentismade.Defaultsis0.
type-[optional]whenpaymentsaredue.0=endofperiod.1=beginningofperiod.Defaultis0.
Checktheexamplefileexceltovba.com-NPER.xlsx
Inthisexamplewearefindingouttheperiodbyinvestingatthebeginningoftheperiodandattheendoftheperiod.Byentering1asfifthparameterwillcalculatethepaymentatthebeginningoftheperiodandthepresentvalueofinvestmentisshownasnegativebecausecashhavebeenflownout.
Pointstonote.
Interestrateis8%whichwearedividingby12togetthemonthlyinterestrateandperiodis48(12monthsx4).Ifyouarepayingquarterly,ratewillbe8%/4and16(4periodx4years)willbethenper.
PMTnormallyincludesprincipalandinterestbutnottaxes,reservepayments,feesoranyothercharges.
4.6.RATEThisfunctionwillreturntheinterestrateperperiodofanannuity
Syntax:
=RATE(nper,pmt,pv,[fv],[type],[guess])
Parameterlist:
nper-thetotalnumberofpaymentperiods.
pmt-thepaymentmadeeachperiodandwillnotbechanged.
pv-thepresentvalue,ortotalvalueofallloanpaymentsnow.
fv-[optional]thefuturevalue,oracashbalanceyouwantafterthelastpaymentismade.Defaultsto0(zero).
type-[optional]whenpaymentsaredue.0=endofperiod.1=beginningofperiod.Defaultis0.
guess-[optional]yourguessontherate.Defaultis10%.
Checktheexamplefileexceltovba.com-RATE.xlsx
Inthisexamplefilewearefirstfindingoutthemonthlyrateandthenconvertingtoannualratebymultiplyingwith12.
Pointstonote.
RATEiscalculatedbyiteration.IftheresultsofRATEdonotconvergewithin0.0000001after20iterations,RATEreturnsthe#NUM!errorvalue.
Youmustbeconsistentwithunitsforguessandnper.Ifyoumakemonthlypaymentsonafive-yearloanat8percentannualinterest,use8%/12forguessand5*12fornper.Ifyoumakeannualpaymentsonthesameloan,use8%forguessand5fornper.
5.Information5.1.CELLThisfunctionwillprovidetheinformationaboutacellandreturnsatextvalue.UseCELLtoextractawiderangeofinformationaboutreferencebysupplyingtheinfo_typeyousupply.
Syntax:
=CELL(info_type,[reference])
Parameterlist:
info_type-thetypeofinformationtoreturnaboutthereference,info_typeisgivenbelow.
reference-[optional]Thereferencefromwhichtoextractinformation.
Pointstonote.
Alwayswraptheinfo_typeindoublequotes.Fortheformula:=CELL(“col”,C19)willreturn3.Seebelowforafulllistofinfo_typesandakeytothecodesthatCELLreturnswhentheinfo_typeisformat.
Whenreferencereferstomorethanonecell,CELLwillreturninformationaboutthefirstcellinreference.
IfyoualreadyappliedtheInfo_typeargumentintheCELLfunctionas“format”andyoulaterapplyadifferentformattothereferencedcell,youmustrecalculatetheworksheettoupdatetheresultsoftheCELLfunction
Thefollowinginfo_typescanbeusedwiththeCELLfunction:
info_typeDescription
“address”Referenceofthefirstcellinreference,astext.
“col”Columnnumberofthecellinreference.
“color”Thevalue1ifthecellisformattedincolorfornegativevalues;otherwisereturns0(zero).
“contents”Valueoftheupper-leftcellinreference;notaformula.
“filename”Filename(includingfullpath)ofthefilethatcontainsreference,astext.Returnsemptytext(””)iftheworksheetthatcontainsreferencehasnotyetbeensaved.
“format”Textvaluecorrespondingtothenumberformatofthecell.Thetextvaluesforthevariousformatsareshowninthefollowingtable.Returns“-”attheendofthetextvalueifthecellisformattedincolorfornegativevalues.Returns“()”attheendofthetextvalueifthecellisformatted
withparenthesesforpositiveorallvalues.
“parentheses”Thevalue1ifthecellisformattedwithparenthesesforpositiveorallvalues;otherwisereturns0.
“prefix”Textvaluecorrespondingtothe“labelprefix”ofthecell.Returnssinglequotationmark(‘)ifthecellcontainsleft-alignedtext,doublequotationmark(“)ifthecellcontainsright-alignedtext,caret(^)ifthecellcontainscenteredtext,backslash(\)ifthecellcontainsfill-alignedtext,andemptytext(””)ifthecellcontainsanythingelse.
“protect”Thevalue0ifthecellisnotlocked;otherwisereturns1ifthecellislocked.
“row”Rownumberofthecellinreference.
“type”Textvaluecorrespondingtothetypeofdatainthecell.Returns“b”forblankifthecellisempty,“l”forlabelifthecellcontainsatextconstant,and“v”forvalueifthecellcontainsanythingelse.
“width”Columnwidthofthecell,roundedofftoaninteger.Eachunitofcolumnwidthisequaltothewidthofonecharacterinthedefaultfontsize.
IfyouareusingtheInfo_typeargumentas“format”thenyouwillgetthecellformatofthecellyourarereferringtoasperthedetailsgivenbelow.ForexampleifthecellformatisGeneralyouwillgetGandifitisnumberyouwillgetF2.
IftheExcelformatisTheCELLfunctionreturns
General“G”
0“F0”
#,##0“,0”
0“F2”
#,##0.00“,2”
$#,##0_);($#,##0)“C0”
$#,##0_);[Red]($#,##0)“C0-”
$#,##0.00_);($#,##0.00)“C2”
$#,##0.00_);[Red]($#,##0.00)“C2-”
0%“P0”
0.00%“P2”
0.00E+00“S2”
#?/?or#??/??“G”
m/d/yyorm/d/yyh:mmormm/dd/yy“D4”
d-mmm-yyordd-mmm-yy“D1”
d-mmmordd-mmm“D2”
mmm-yy“D3”
mm/dd“D5”
h:mmAM/PM“D7”
h:mm:ssAM/PM“D6”
h:mm“D9”
h:mm:ss“D8”
Checktheexamplefileexceltovba.com-CELL.xlsx
InthisexamplefirstwearecalculatingthecolumnnumberofthecellE20usingCELLfunctionsfirstparameter“col”.SecondwearecalculatingtherownumberofthecellA25using“row”asthefirstparameter.
Thirdweareusingthe“contents”asthefirstparametertofindthecontentsofthecellA3whichis“GoodMorning”.Fourthwearefindingthetypeofthecellcontentusingthe“type”asthefirstparameterwhichisthedatatypevaluewhichisv.
FifthandSixthweareusingthefirstparameteras“format”tofindouttheformatofthecellcontentsmentionedinthesecondparameter.Fifthwearegetting‘G’becausethecellcontentofA4isGeneralformatsowewillgettheanswerG.LikewisethecontentofA5isformattedasnumbersowewillgettheanswerasF2.
5.2.INFOThisfunctionreturnstheinformationaboutthecurrentoperatingenvironment.
Syntax:
=INFO(type_text)
Parameterlist:
type_text-textthatspecifieswhattypeofinformationyouwantreturned.
PointstoNote.
BelowaretheType_textyoucanuseandthecorrespondingdetailsyouwillgetwhenyouusethetype_text.
Type_textReturns
“directory”Pathofthecurrentdirectoryorfolder.
“numfile”Numberofactiveworksheetsintheopenworkbooks.
“origin”Returnstheabsolutecellreferenceofthetopandleftmostcellvisibleinthewindow,basedonthecurrentscrollingposition,astextprependedwith“$A:”.Theactualvaluereturneddependsonthecurrentreferencestylesetting.UsingD9asanexample,thereturnvaluewouldbe:
A1referencestyle“$A:$D$9”.
R1C1referencestyle“$A:R9C4”
“osversion”Currentoperatingsystemversion,astext.
“recalc”Currentrecalculationmode;returns“Automatic”or“Manual”.
“release”VersionofMicrosoftExcel,astext.
“system”Nameoftheoperatingenvironment:
Macintosh=“mac”
Windows=“pcdos”
Examples:
=INFO(“numfile”)Willreturnnumberofactiveworksheets.
=INFO(“recalc”)Willreturnrecalculationmodefortheworkbook.
5.3.ISBLANKThisfunctiontestsifacellisemptyandreturnsalogicalvalue(TRUEorFALSE).Forexample,=ISBLANK(A1)willreturnTRUEifA1isempty,andFALSEifA1containstextorformulas.Sometimesthecelllooksemptybutmaynotbethecasebe.
Syntax:
=ISBLANK(value)
Parameterlist:
value-thevaluetocheck.
Checktheexamplefileexceltovba.com-ISBLANK.xlsx
InthisexamplefourthrowreturnsTRUEasA4cellisactuallyempty.A2andA5hasvaluesinitandreturnsFALSEandA3andA6returnsfalsebecauseA3hasasinglequoteandA6hasasinglespacewhichisnotvisiblewhenyouseetheExcelsheet.
5.4.ISERRThisfunctionchecksforanyerrorvalueexcept#N/AandreturnsalogicalvalueTRUEorFALSE.
Syntax:
=ISERR(value)
Parameterlist:
value-thevaluetocheckforanyerrorbut#N/A.
Checktheexamplefileexceltovba.com-ISERR.xlsx
IntheExampleyoucanseeexcept#N/AerrorrestoftheerrorswearegettingtheresultasTrue.
Pointstonote.
UsetheISERRfunctiontoseeifacellhasanerrorexceptfor#N/A.Thisincludes#VALUE!,#REF!,#DIV/0!,#NUM!,#NAME?,or#NULL!.Normallythevalueissuppliedasacelladdresssothatyoucanclubandusethiswithotherfunction.
5.5.ISERRORThisfunctionchecksforanyerrorvalue(#N/A,#VALUE!,#REF!,#DIV/0!,#NUM!,#NAME?,or#NULL!)andreturnsalogicalvalueTRUEorFALSE.
Syntax:
=ISERROR(value)
Parameterlist:
value-thevaluetocheckforanyerror.
5.6ISEVENThisfunctionisusedtocheckwhetherthenumericvalueisanevennumberandreturnsTRUEifthenumberisevenorelsewillreturnFALSE.Ifvalueisnotnumeric,ISEVENwillreturnthe#VALUEerror.
Syntax:
=ISEVEN(value)
Usually,valueissuppliedasacelladdresslikethis=ISEVEN(A1)
=ISEVEN(2)willreturnTRUE.
=ISEVER(1)willreturnFALSE.
5.7.ISFORMULAThisfunctionreturnsTRUEifacellcontainsaformulaorelseitwillreturnFALSE.Forexample=ISFORMULA(A1)willreturnTRUEiftheA1cellhasanyformulalike=SUM(A4:A5)or=A4+A5.ThisfunctionisintroducedinExcel2013.
Syntax:
ISFORMULA(reference)
Parameterlist:
reference-referencetothecellyouwanttotest,canbeacellreference,aformula,oranamethatreferstoacell.
5.8.ISLOGICALThisfunctionchecksifavalueislogical(TRUEorFALSE)andreturnalogicalvalue(TRUEorFALSE).
Syntax:
=ISLOGICAL(value)
Parameterlist:
value-thevaluetotestaslogical.
Pointstonote.
1and0(zero)arenotevaluatedasTRUEandFALSE.
5.9.ISNAThisfunctionwilltestforthe#N/AerrorandreturnsTRUEwhenvalueis#N/AandFALSEifnot.
Syntax:
=ISNA(value)
Parameterlist:
value-thevaluetocheckif#N/A.
Normallyvalueissuppliedasacelladdresslikethis=ISNA(B2).
5.10.ISNONTEXTThisfunctiontestsforanon-textvalueandreturnsalogicalvalueTRUEorFALSE.ISNONTEXTwillreturnTRUEwhenvalueisanon-textvalueandFALSEifnot.ISNONTEXTwillalsoreturnTRUEforblankcells.
Syntax:
=ISNONTEXT(value)
Parameterlist:
value-thevaluetocheck.
Often,valueissuppliedasacelladdress.
5.11.ISNUMBERThisfunctionwillreturnTRUEifvalueisanumberandFALSEifnot.Forexample,=ISNUMBER(A1)willreturnTRUEifA1containsanumberoraformulathatreturnsanumericvalue.IfA1containstext,ISNUMBERwillreturnFALSE.
Syntax:
=ISNUMBER(value)
Parameterlist:
value-thevaluetocheck.
Checktheexamplefileexceltovba.com-ISNUMBER.xlsx
InthesameexamplefileopenthesecondSheet2,inthatwearefirstcheckingwhetheranynumberisenteredinthecellC8usingISNUMBERandifnumberisenteredthenIFfunctionwillcallthefirstVLOOKUPformulatosearchusingtheEmployeenumberandifthenameisenteredthenIFfunctionwillcallsecondVLOOKUPtosearchbyname..
Formulaused=IF(ISNUMBER(C8),VLOOKUP(C8,$A$2:$C$6,3,0),VLOOKUP(C8,$B$2:$C$6,2,0))
5.12.ISODDThisfunctiontestsifavalueisoddandreturnsTRUEwhenanumericvalueisoddandFALSEwhenanumericvalueiseven.Forexample,=ISODD(A1)willreturnTRUEifA1containsthenumber7andFALSEifA1containsthenumber6.
Usuallythevalueissuppliedasacelladdress.
Syntax:
=ISODD(number)
Parameterlist:
number-thenumericvaluetotestandifnumberisnotanintegeritistruncated.
Checktheexamplefileexceltovba.com-ISODD.xlsx
5.13.ISREFThisfunctionchecksthevalueisareference.ISREFwillreturnTRUEwhenvalueisareferenceandFALSEifnot.
Syntax:
=ISREF(value)
Parameterlist:
value-Thevaluetocheck.
Forexample,=ISREF(A1)willreturnTRUEand=ISREF(“apple”)willreturnfalse.
5.14.ISTEXTThisfunctionchecksifthevalueistext.ISTEXTwillreturnTRUEwhenvalueistextorelseitwillreturnFALSE.
Syntax:
=ISTEXT(value)
Parameterlist:
value-thevaluetocheck.
Forexample,=ISTEXT(A1)willreturnTRUEifA1contains“James”.Often,valueissuppliedasacelladdress.
5.15.NThisfunctionconvertsavaluetoanumber.
Syntax:
=N(value)
Parameterlist:
value-thevaluetoconverttoanumber.
Valueswillbeconvertedasgivenbelowwhenusingthisfunction.
Anumberwillreturnthatnumberitself.
Adate,inoneofthebuilt-indateformatsavailableinMicrosoftExcelwillreturntheserialnumberofthatdate
IfthevalueisTRUEitwillreturn1.
IfthevalueisFALSEitwillreturn0.
Ifitisanerrorvalue,suchas#DIV/0!Itwillreturntheerrorvalueitself.
Andanythingelsethisfunctionwillreturn0.
InmostcasesitunnecessarytousetheNfunctionasExcelautomaticallyconvertsvaluesasnecessary.Thisfunctionisprovidedforcompatibilitywithotherspreadsheetprograms.
ThereisatrickyuseofN()thatallowsyoutouseitasawaytoleavein-cellcomments.ThetechniqueistoaddaplussignattheendofyourformulawithacommentastextinquotesinsidetheN()functionlikethis:
=SUM(A1:A10)+N(“ThisoneaddsthecellsfromA1toA10”)
Whenyouclickonthatcell,you’llseeboththeformulaandthecommentintheformulabar.TheN()functionhasnoimpactontheresultofthefunction.Infact,youcanaddmorethanoneN()functiontoaformulatoannotateotherfunctions,constants,orboth.
5.16.NA
Thisfunctioncreatesa#N/Aerror.InotherwordsUseNAtogeneratethe#N/A.#N/Ameans“notavailable”or“novalueavailable”.Forexample,youcanuseNAtoflagcellsthatareemptyormissinginformation
Syntax:
=NA()
Pointstonote.
NAtakesnoarguments,butyoumustprovideemptyparentheses.
5.17.TYPEThisfunctionreturnsanumericcoderepresentingthetypeofvalueinacell.UseTYPEwhenthebehaviorofanotherfunctiondependsonthetypeofvalueinaparticularcell.
Syntax:
=TYPE(value)
Parameterlist:
value-thevaluetocheckthetypeof.
IfthevalueisNumberTYPEreturns1.
IfthevalueisTextTYPEreturns2.
IfthevalueisLogicalvalueTYPEreturns4.
IfthevalueisErrorvalueTYPEreturns16.
IfthevalueisArrayTYPEreturns64.
Pointstonote.
TYPEismostusefulwhenyouareusingfunctionsthatcanacceptdifferenttypesofdata,suchasARGUMENTandINPUT.UseTYPEtofindoutwhattypeofdataisreturnedbyafunctionorformula.
YoucannotuseTYPEtodeterminewhetheracellcontainsaformula.TYPEonlydeterminesthetypeoftheresulting,ordisplayed,value.Ifvalueisacellreferencetoacellthatcontainsaformula,TYPEreturnsthetypeoftheformula’sresultingvalue.
6.Logical6.1.ANDThisfunctiontestsmultipleconditionsandreturnsTRUEifallargumentsevaluatetoTRUEelseitwillreturnFALSE.
Syntax:
=AND(logical1,[logical2],…)
Parameterlist:
logical1-thefirstconditionorlogicalvaluetoevaluate.
logical2-[optional]thesecondconditionorlogicalvaluetoevaluate.Uptoamaximumof255conditions.
Pointstonote.
Theargumentsmustevaluatetologicalvalues,suchasTRUEorFALSE,ortheargumentsmustbearraysorreferencesthatcontainlogicalvalues.
Ifanarrayorreferenceargumentcontainstextoremptycells,thosevaluesareignored.
Ifthespecifiedrangecontainsnologicalvalues,theANDfunctionreturnsthe#VALUE!errorvalue.
Pleasegothroughtheexamplesgivenbelow.
=AND(TRUE,TRUE)willreturnTRUEbecausealltheargumentsareTRUE.
=AND(TRUE,FALSE)willreturnFALSEbecauseoneoftheargumentisFALSE.
=AND(2+4=6,4+5=9)willreturnTRUEbecauseboththecasesaretrue2+4is6and4+5is9.
ItcanbeusefultoextendthefunctionalityoffunctionslikeIF.
=IF(AND(A1>0,A1<5),“Approved”,“Denied”)
Thisformulawillreturn“Approved”onlyifthevalueinA1isgreaterthan0andlessthan5.
Inthebelowexamplewearecalculatinghowmanyofthestudentshavescored50marks(passingmark)ormoreinallsubjects,wewillgetTRUEifallthestudentshavescored50orabove.
Checkexceltovba.com-AND.xlsx
6.2.IFThisfunctionwilltestforaspecificconditionandreturnsthevalueyoursupplyifaconditionistrueandanothervalueifit’sfalse.
Syntax:
=IF(logical_test,[value_if_true],[value_if_false])
Parameterlist:
logical_test-avalueorlogicalexpressionthatcanbeevaluatedasTRUEorFALSE.
value_if_true-thevaluetoreturnwhenlogical_testevaluatestoTRUE.
value_if_false-[optional]Thevaluetoreturnwhenlogical_testevaluatestoFALSE.
WhenyouareconstructingatestwithIF,youcanuseanyofthefollowinglogicaloperators:
ComparisonoperatorMeaningExample
=equaltoA1=D1
>greaterthanA1>D1
>=greaterthanorequaltoA1>=D1
<lessthanA1<D1
<=lessthanorequaltoA1<=D1
<>notequaltoA1<>D1
PleasegothroughtheexamplesgivenbelowtofurtherillustratetheuseofIF.
Example1.
Checkexceltovba.com-IF.xlsx.
HerewearecheckingwhethertheSalestargetofeachemployeehasmetandiftheparticularemployeehasachievedtheTarget,CompanywillbegivetenpercentoftheSalesascommissionorelsewillprovidefivepercent.
SointheResultsColumnweareusingtheformula=IF(B2>=C2,“Achieved”,“NotAchieved”)tofindoutwhethertheemployeeshasachievedtheTargetandinthecommissioncolumnwearecalculatingthecommissionusingtheformula=IF(B2>=C2,B2*10%,B2*5%).Insteadofhardcodingthepercentages10and5youcanenterthevalueascellreferencesothatifthecommissionratechangesyouhavetojustchangetwocellvaluesonly.
Example2.
Checkexceltovba.com-IF-2.xlsx
Herewearecheckingwhetherthereisspecialofferfortheproductandtheordervaluecrossesthousanddollars.Ifthesetwoconditionsaremetthenwewillprovideadiscountof10percent.Sointhediscountcolumnwearecalculatingthediscountamountusingtheformula=IF(AND(B2=“Yes”,C2>=1000),C2*10%,0).
HerewearefirstcheckingwhetherthewordYesiswrittenintheSpecialoffercolumnandtheOrdervalueisgreaterthan1000usingtheANDfunction.IfthesetwoconditionsaremetthenIFformulawillcalculatethetenpercentdiscountorelseitwillreturn0tothediscountcolumn.
OncethatisdonewewilldeductthediscountfromOrdervaluetoreachthefinalamounttopay.
6.3.IFERROR
Thisfunctionreturnsavalueyouspecifyifaformulaevaluatestoanerror;otherwise,returnstheresultoftheformula.UsetheIFERRORfunctiontotrapandhandleerrorsinaformula.
Syntax:
=IFERROR(value,value_if_error)
Parameterlist:
value-thevalue,reference,orformulatocheckforanerror.
value_if_error-thevaluetoreturniftheformulaevaluatestoanerror.Thefollowingerrortypesareevaluated:#N/A,#VALUE!,#REF!,#DIV/0!,#NUM!,#NAME?,or#NULL!.
Pointstonote.
IfValueorValue_if_errorisanemptycell,IFERRORtreatsitasanemptystringvalue(””).
IfValueisanarrayformula,IFERRORreturnsanarrayofresultsforeachcellintherangespecifiedinvalue.
Thisfunctionisveryuseful,ifyoucomparingtwoexcelsheetsusingVlookupformulaandyouwillget#N/AerrorifthevalueisnotthereinotherExcelsheet.Supposeyouaredoingsomecalculationsbasedontheresultlikemultiplyingthevaluesthenitwillresultinanother#N/Aerror.SotoavoidyoucanputtheVLOOKUPformulainsideIFERRORlikethis=IFERROR(VLOOKUP(A1,table,2,FALSE),0)toget0ifthereisanerror.
OrelsewecanreturnthetextlikethisNotfound.Youcanwritetheformulalikethis=IFERROR(VLOOKUP(A1,table,2,FALSE),”NotFound”)
6.4.NOTThisfunctionreversesthevalueofitargumentsandreturnsareversedlogicalvalue.InotherwordsifanyoftheformulasevaluatestoTRUEandifyouusethisfunctionyouwillgetFALSEandyouwillgetTRUEiftheformulaevaluatestoFALSE.
Syntax:
=NOT(logical)
Parameterlist:
logical-avalueorlogicalexpressionthatcanbeevaluatedasTRUEorFALSE.
Examplesgivenbelow.
=NOT(FALSE)willgiveyoutheanswerTRUEasitreversedthelogicalvalue.
=NOT(4+4=8)willgiveyouthevalueFALSEbecausesumof4+4is8andistrueanditreversesthelogicalvaluetoFALSE.
=NOT(4+3=8)willgiveyouthevalueTRUEbecausesumof4+3isnot8andisfalseandsoitreversesthelogicalvaluetoTRUE.
Whywouldyouwanttousethisfunction?Acommonexampleistoreversethebehaviorofanotherfunction.Forexample,IfthecellA1isblank,thentheformula=ISBLANK(B1)willreturnTRUE.
NOTcanbeusedtoreversethisresulttoFALSElikethis:
=NOT(ISBLANK(A1))
Inessence,byaddingNOT,youareabletocreateaformulathatbehaveslikeISNOTBLANK,whichdoesn’texistinExcel.
6.5.ORThisfunctiontestsmultipleconditionswithORandreturnsTRUEifanyoftheargumentsiscorrectandFALSEifnot.Upto255conditionsyoucancheck.
Syntax:
=OR(logical1,[logical2],…)
Parameterlist:
logical1-Thefirstconditionorlogicalvaluetoevaluate.
logical2-[optional]thesecondconditionorlogicalvaluetoevaluate.
Pointstonote.
TheargumentsmustevaluatetologicalvaluessuchasTRUEorFALSE,orinarraysorreferencesthatcontainlogicalvalues.
Ifanarrayorreferenceargumentcontainstextoremptycells,thosevaluesareignored.
Ifthespecifiedrangecontainsnologicalvalues,ORreturnsthe#VALUE!errorvalue.
YoucanuseanORarrayformulatoseeifavalueoccursinanarray.Toenteranarrayformula,pressCTRL+SHIFT+ENTER.
Examples:
=OR(TRUE)willgettheanswerastruebecauseoneargumentisTRUE.
=OR(2+2=1,2+8=5)willgettheanswerasFALSEasboththeargumentsarewrong,2+2isnot1and2+8isnot5.
=OR(TRUE,FALSE,TRUE)willgetTRUEoneoftheargumentisTRUE
=IF(OR(3+1=1,2+9=5,5+15=20),“Correct”,“NotCorrect”)willgettheanswerCorrectasoneoftheargumentsistrue.InthiscaseyouarenestingitwithanotherfunctionIFsothatyoucandefineyourownwordsasanswerinthiscaseCorrectorifyouwanttogetananswerasYEStheninsteadofCorrectusethewordYES.
=IF(OR(A1>75,B1<75),“Pass”,“Fail”)willgetPassifthevalueinA1isgreaterthan75orthevalueinB1islesserthan75orelsewewillgettheanswerFail.
InthebelowexamplewearecalculatingtheprocessingchargesforthepaymentwehavereceivedasCashorCheque.IfitisCashorChequewewillchargeRs.10.SointhiscaseweareclubbingthefunctionIFtogettheresults.
Checkexceltovba.com-OR.xlsx
InthebelowexamplewearecalculatingtheprocessingchargesforthepaymentwehavereceivedasCashorCheque.IfitisCashorChequewillchargeRs.10asprocessingchargeandifitisatransfertherewon’tbeanycharge.SointhiscaseweareclubbingthisfunctionwithIFtogettheresults.
6.6.FALSEThisfunctiongeneratesthelogicalvalueFALSE.
Syntax:
=FALSE()
TheFALSEfunctiontakesnoarguments.UseFALSEtogeneratethelogicalvalueFALSE.Forexample,toreturnFALSEifthevalueinA1<0,usetheformula:
=IF(A1<0,FALSE())
NotethatyoucanalsojustuseenterthewordFALSEdirectlyintoacellorformulaandExcelwillinterpretthisasthelogicalvalueFALSE.Forexample,theseformulasarefunctionallyidentical:
=IF(A1<0,FALSE())
=IF(A1<0,FALSE)
TheFALSEfunctionisprovidedprimarilyforcompatibilitywithotherspreadsheetprograms.
6.7.TRUEThisfunctiongeneratesthelogicalvalueTRUE.
Syntax:
=TRUE()
TheTRUEfunctiontakesnoarguments.
MicrosofthasprovidedTRUEfunctionforcompatibilitywithotherspreadsheetapplicationsandthereisnoneedtouseitinalmostallcases.
IfyouwanttoenterTRUE,orprovideTRUEasaresultinaformula,youcanjustuseenterthewordTRUEdirectlyintoacellorformulaandExcelwillinterpretthisasthelogicalvalueTRUE.Forexample,theseformulasarefunctionallyidentical:
=IF(A1<0,TRUE())
=IF(A1<0,TRUE)
AlsonotethatlogicalexpressionsthemselveswillautomaticallygenerateTRUEandFALSEresults.ForexampleifthecellB7hasthevalue110then=B7>90willreturnthelogicalvalueTRUE.
6.8.IFNAThisfunctionreturnsthevalueyouspecifyiftheformulareturns#N/A;errorotherwise,returnstheresultoftheformula.ThisfunctionwasintroducedinExcel2013.
Syntax:
IFNA(value,value_if_na)
Parameterlist:
Value-theformulathatischeckedforthe#N/Aerrorvalue.
Value_if_na-thevaluetoreturniftheformulaevaluatestothe#N/Aerrorvalue.
Pointstonote.
IfValueorValue_if_naisanemptycell,IFNAtreatsitasanemptystringvalue(””).
IfValueisanarrayformula,IFNAreturnsanarrayofresultsforeachcellintherangespecifiedinvalue.
Forexampleinthisformula=IFNA(VLOOKUP(“Joy”,$A$5:$B$10,0),“Notfound”)ifthenameJoyisnotthereinthelookuptableitwillreturn#N/AerrorandIFNAfunctionwillreturnNotFoundwhichyouhavespecifiedattheendoftheformula.
7.Lookupandreference7.1.ADDRESSThisfunctioncreatesacelladdressfromagivenrowandcolumn.Forexample,ADDRESS(5,3)returns$C$5.Asanotherexample,ADDRESS(250,53)returns$BA$250.Youcanuseotherfunctions,suchastheROWandCOLUMNfunctions,toprovidetherowandcolumnnumberargumentsfortheADDRESSfunction.
Syntax:
=ADDRESS(row_num,col_num,[abs_num],[a1],[sheet_text])
Parameterlist:
row_num-therownumbertouseinthecelladdress.
col_num-thecolumnnumbertouseinthecelladdress.
abs_num-[optional]theaddresstype(i.e.absolute,relative).Defaultstoabsolute.
a1-[optional]thereferencestyle,A1vsR1C1.DefaultisA1style.
sheet_text-[optional]thenameoftheworksheettouse.Defaultstocurrentsheet.
Abs_numkey:
1oromittedAbsolute
2Absoluterow;relativecolumn
3Relativerow;absolutecolumn
4Relative
a1–Thisisoptional
AlogicalvaluethatspecifiestheA1orR1C1referencestyle.InA1style,columnsarelabeledalphabetically,androwsarelabelednumerically.InR1C1referencestyle,bothcolumnsandrowsarelabelednumerically.IftheA1argumentisTRUEoromitted,theADDRESSfunctionreturnsanA1-stylereference;ifFALSE,theADDRESSfunctionreturnsanR1C1-stylereference.
sheet_text-ThisisOptional.
Atextvaluethatspecifiesthenameoftheworksheettobeusedastheexternalreference.
Forexample,theformula=ADDRESS(1,1,,,“Sheet2”)returnsSheet2!$A$1.Ifthesheet_textargumentisomitted,nosheetnameisused,andtheaddressreturnedbythefunctionreferstoacellonthecurrentsheet.
Examples:
=ADDRESS(5,3)returns$C$5
=ADDRESS(5,3,2)returnsC$5,AbsoluterowandRelativecolumn.
=ADDRESS(5,3,2,FALSE)returnsR5C[3]absoluterow;relativecolumninR1C1referencestyle
7.2.AREASThisfunctionreturnsthenumberofareasinareference.
Syntax:
=AREAS(reference)
Parameterlist:
reference-areferencetoacellorrangeofcells.
Usagenotes:
Referencecanincludemorethanonereference.Youmustseparatemultiplereferenceswithacommaandwraptheminanextrasetofparentheses.Otherwise,Excelwillthinkthecommasindicatemultipleparametersandgenerateanerror.
Examples:
=AREAS((E17:E19,K16:K18,M8))willreturn3astherearethreereferences.
=AREAS(B2:D4)willreturn1asthereisonlyonereference.
7.3.CHOOSEThisfunctionwillreturnavaluefromalistbasedonindexnumberyouspecify.Forexampleiftherearethreevaluesandyouspecifytheindexnumberas1itwillreturnthefirstvalueandifyouspecify2itwillreturnthesecondvalue.
Syntax:
=CHOOSE(index_num,value1,[value2],…)
Parameterlist:
index_num-thevaluetochoose.Anumberbetween1and254.
value1-thefirstvaluefromwhichtochoose.
value2-[optional]thesecondvaluefromwhichtochoose.
Pointstonote.
Ifindex_numislessthan1orgreaterthanthenumberofthelastvalueinthelist,CHOOSEreturnsthe#VALUE!errorvalue.
Ifindex_numisafraction,itistruncatedtothelowestintegerbeforebeingused.
Ifindex_numisanarray,everyvalueisevaluatedwhenCHOOSEisevaluated.
ThevalueargumentstoCHOOSEcanberangereferencesaswellassinglevalues.
Forexample,theformula=SUM(CHOOSE(2,A1:A10,B1:B10,C1:C10))willfirstevaluatetheCHOOSEfunctiontoreturn=SUM(B1:B10)thesecondrangebasedontheindexnumberyouhavespecified,inthiscase2.
7.4.COLUMNThisfunctionwillreturnthecolumnnumberofareference.
Syntax:
=COLUMN([reference])
Parameterlist:
reference-[optional]referencetoacellorrangeofcells.
Pointstonote.
Referencecanbeasinglecelladdressorarangeofcells.
ReferenceisoptionalandwilldefaulttothecellinwhichtheCOLUMNfunctionexists.
Referencecannotincludemultiplereferencesoraddresses.
Examples:
=COLUMN()willreturnthecolumnnumberinwhichthisformulaisentered.IfyouhaveenteredinA1youwillgetcolumnnumberas1.
=COLUMN(B1:Z1)willreturnthecolumnnumberas2asthecellrangestartsfromsecondcolumn.Othercolumnswillnotbeconsidered.
7.5.COLUMNS
Thisfunctionwillreturnthenumberofcolumnsinanarrayorreference.Forexample,theformula=COLUMNS(A1:E1)returnsthenumber5astherearefivecolumnsfromAtoE.
Syntax:
=COLUMNS(array)
Parameterlist:
array-Areferencetoarangeofcells.
Pointstonote.
Arraycanbeanarray,anarrayformula,orareferencetoasinglecontiguousgroupofcells.
Examples:
=COLUMNS(B1:Z1)willreturn25asthereare25columnsfromBtoZ.
=COLUMNS({1,2,3,4;5,6,7,8})willreturnthecolumnnumberas4.Therearetwo4-columnrows,containing1,2,3and4inthefirstrowand5,6,7and8inthesecondrow.
7.6.HLOOKUPThisfunctionsearchesforavalueinthefirstrowofatable.Atthematchcolumn,itretrievesavaluefromthespecifiedrow.UseHLOOKUPwhenlookupvaluesarelocatedinthefirstrowofatable.ThisfunctionissamelikeVLOOKUP,whereasVLOOKUPsearchesvertically,HLOOKUPsearcheshorizontally.
Thisfunctionwilllookupavalueinatablebymatchingonthefirstrow.
Syntax:
=HLOOKUP(lookup_value,table_array,row_index_num,[range_lookup])
Parameterlist:
lookup_value-thevaluetolookup.
table_array-thetablefromwhichtoretrievedata.
row_index_num-therownumberfromwhichtoretrievedata.
range_lookup-[optional]abooleantoindicateexactmatchorapproximatematch.DefaultisTRUE=approximatematch,FALSE=exactmatch.
Pointstonote.
Range_lookupcontrolswhethervalueneedstomatchexactlyornot.ThedefaultisTRUE=allownon-exactmatch.
Setrange_lookuptoFALSEtorequireanexactmatchandvaluesinthefirstrowoftabledonotneedtobesorted.
Ifrange_lookupisTRUE(thedefaultsetting),anon-exactmatchwillcausethe
HLOOKUPfunctiontomatchormatchthenearestvalueinthetablethatisstilllessthanvalue.
Ifrange_lookupisTRUE(thedefaultsetting)makesurethatlookupvaluesinthefirstrowofthetablearesortedinascendingorder.Otherwise,HLOOKUPmayreturnanincorrectorunexpectedvalue.
Iftherearemorethanonevalueinthetableyouarelookingthisfunctionwillpickthefirstvalueonly.
ChecktheexampleHLOOKUP.XLSXSheet1
InthisexamplewearecheckinghowmuchmarksArnoldandJomyearnedinPhysicsandMaths.TherearefourparameterswehavetosupplytoHLOOKUP.
FirstparameterwearesearchingthenameArnoldorJomysowewillprovidethesameindoublequotes(textshouldbeprovidedindoublequotes).
Secondparameteriswherewearegoingtosearch,sincetheentirenameandmarkdetailsareintherangeB1:E4wewillprovidethatassecondparameter.
Thirdparameterweareprovidingtherownumber,2forPhysics3forMaths.(Countingfromthenamerow)
Fourthparameterweareentering0orFalsetogetanexactmatch.
ChecktheexampleHLOOKUP.XLSXSheet2
Inthisexamplefileweareusingthewildcardcharacters.*isusedforsearchingmultiplenumberofcharacters,m*canbeMelvinorMijoorwhateverstartswithm.?meanssinglecharacter,melvi?meansMelvinormelvihormelvip.Restoftheentriesaresamelikethepreviousexample.
7.7.HYPERLINKThisfunctioncreatesaclickablelink.
Syntax:
=HYPERLINK(link_location,[friendly_name])
Parameterlist:
link_location-thepathtothefileorpagetobeopened.
friendly_name-[optional]thelinktexttodisplayinacell.
Usagenotes:
UsetheHYPERLINKfunctiontocreatelinkstoworkbooklocations,pagesontheinternet,ortofilesonnetworkservers.
WhenauserclicksacellthatcontainstheHYPERLINKfunction,Excelwillopenthefileorpagespecifiedbylinklocation.Link_locationcanbeacellreferenceornamedrange,apathtoafilestoredonalocaldrive,apathafileonaserverusingUniversalNamingConvention(UNC)orapathtoalocationontheinternetoranintranetinUniformResourceLocator(URL)format.
Pointstonote.
Link_locationshouldbesuppliedasatextstringinquotationmarksoracellreferencethatcontainsthelinkpathastext.
Iffriendly_nameisnotsupplied,theHYPERLINKwilldisplaylink_locationasthefriendly_name.
ToselectacellthatcontainsHYPERLINKwithoutjumpingtothedestination,usearrowkeystoselectthecell.Alternatively,clickonthecellandholdthemousebuttondownuntilthecursorchanges.
Examples:
=HYPERLINK(“http://amazon.com”,“Clickme”)willcreatealinkinExcelwiththetextClickmeandifyouclickthelinkitwillopenthesiteamazon.com.
=HYPERLINK(“[C:\MyDocuments\Report.xlsx]Quarter”)willcreateahyperlinktoanExcelfileReportsheetnameQuarter.
7.8.INDEXThisfunctionpicksavalueinalistortablebylookingdownthespecifiedrowsandlookingacrossthespecifiedcolumns.
Syntax:
=INDEX(array,row_num,[col_num],[area_num])
Parameterlist:
array-arangeofcells,oranarrayconstant.
row_num-therowpositioninthereferenceorarray.
col_num-[optional]thecolumnpositioninthereferenceorarray.
area_num-[optional]therangeinreferencethatshouldbeused.
TheINDEXfunctionhastwoforms:ArrayandReference.
Arrayform
InthearrayformofINDEX,thefirstparameterisarray,whichissuppliedasarangeofcellsoranarrayconstant.
Syntax:
INDEX(array,row_num,[col_num])
Ifbothrow_numandcol_numaresupplied,INDEXreturnsthevalueinthecellattheintersectionofrow_numandcol_num.
Ifyourow_numissettozero,INDEXreturnsanarrayofvaluesfortheentirerow.Tousethesearrayvalues,entertheINDEXfunctionasanarrayformulainhorizontalrange.
Ifyoucol_numissettozero,INDEXreturnsanarrayofvaluesfortheentirecolumn.Tousethesearrayvalues,entertheINDEXfunctionasanarrayformulainverticalrange.
Indexcanbeusedinsomanywaysaspertheexamplesgivenbelow.
Example1:
INDEXfunctionwithsecondparameterasrow_num.
Checktheexamplefileexceltovba.com-INDEX.xlsx(sheetname:Index1).
IntheexamplefilewehavetofindoutthesecondvalueintherowusingINDEXfunction.Enter=INDEX(A2:A4,2)sothatyouwillgetthesecondvalueintherowwhichis14,ifyouwantthethirdrowvaluethenyouhavetoenter3asthesecondparametersothatyouwillget15astheanswer.
Example2:
INDEXfunctionwithsecondparameterascol_num.
InthesameexamplefilewehavetofindoutthesecondvalueinthecolumnusingINDEXfunction.Enter=INDEX(B1:E1,2)sothatyouwillgetthesecondvalueinthecolumnwhichisRoy,ifyouwantthethirdcolumnvaluethenyouhavetoenter3asthesecond
parametersothatyouwillgetRubyastheanswer.
Example3:
INDEXfunctionwithsecondparameterbothrow_numandcol_num.
Checktheexamplefileexceltovba.com-INDEX.xlsx(sheetname:Index2).
InthesameexamplefileyouhavetofindoutonDay13howmuchRubyhasearned.Enter=INDEX(B2:E4,2,3)inanyofthecellandyouwillgettheansweras110.Insteadofhardcodingtherownumberandcolumnnumberyoucanusethecellreferencelikethis=INDEX(B2:E4,E6,E7)andinE6cellyoucangivetherownumber2andinE7columnnumber3.
SoifyouwanttofindoutwhatJomyhasearnedonDay15youhavetojustchangethevalueinthecellsE6to3andE7to4.
Referenceform
InthereferenceformofINDEX,thefirstparameterisreference,whichissuppliedasareferencetooneormorecellranges.
Syntax:
INDEX(reference,row_num,[col_num],[area_num])
ThereferenceformofINDEXreturnsthereferenceofthecellattheintersectionrow_numandcol_num.
Ifreferenceissuppliedasmultipleranges,area_numindicateswhichrangetouse.
area_sumissuppliedasanumber.
Forexample,intheformula=INDEX((A1:D5,A7:D10),2,2,2),area_numissuppliedas2,whichreferstotherangeA7:D10.
Youwillgettheideaonceyougothroughtheexamples.
Example4:
Checktheexamplefileexceltovba.com-INDEX.xlsx(sheetname:Index3).
ThisistheadvancedversionoftheExample3astherearetwogroupsFirst(B3:E5)andSecond(B9:E11)insteadofonegroup.Byincludingthearea_numyoucaneasilycheckfromFirstorSecondgrouphowmucheachpersonhasearned.Youhavetoentertheformulalikethis=INDEX((B3:E5,B9:E11),2,3,1)sothatyouwillgettheamountearnedfromthefirstgroupasthefourthparameterdecideswherewehavetolook,1willlookinthefirstgroupand2willlookinthesecondgroup.
Insteadofhardcodingthelastthreeparametersyoucanchangeittocellreferencesothatitwillbeableeasytomanipulatelikethis=INDEX((B3:E5,B9:E11),E13,E14,E15),inthecellE13youcanType1or2or3fortheday,Type1or2or3or4fortheNameincellE14,Type1forFirstand2forSecondgroupincellE15.
Checktheexamplefileexceltovba.com-INDEX.xlsx(sheetname:Index4).
Alsowecanmakethisformulamorereadablebychangingthecellranges(B3:E5,B9:E11)toanamelikeFirstandSecond.FirstselectthecellrangesB3:E5,B9:E11andchangethenametoFirstandSecondinthecellreferencecolumnandthenusethisnameintheformulalikethis=INDEX(FirstandSecond,E13,E14,E15).
Checktheexamplefileexceltovba.com-INDEX.xlsx(sheetname:Index5).
Example5:
Thisistheadvancedversionofthepreviousexample.InthisweareclubbingtogetherMATCHandIFfunctionswithINDEXtoincreasethecapabilities.Formulaisgivenbelowandwillsplittheformulaforyoutounderstand.
=INDEX(FirstandSecond,MATCH(E13,A3:A5,0),MATCH(E14,B2:E2,0),IF(E15=“First”,1,IF(E15=“Second”,2)))
FirstandSecond-Firstparameteristhenamegiventothecellrange(B3:E5,B9:E11).
MATCH(E13,A3:A5,0)-Secondparameterfromwhichwewillgettherowpositionofthedaywehaveentered,inthiscasewewillgetthereturnvalueas1aswearecheckingthepositionnumberofthevalue13inthecellrangeA3:A5.
MATCH(E14,B2:E2,0)–Thirdparameterfromwhichwewillgetthecolumnpositionforthenamewehaveentered,inthiscasewewillgetthereturnvalueas2aswearecheckingthepositionnumberofthevalueArnoldinthecellrangeB2:E2.
IF(E15=“First”,1,IF(E15=“Second”,2))–FourthparameterwearecheckingwhetherwehaveenteredthewordFirstorSecondinthecellE15.IfitisFirstthenIFfunctionwillreturn1andifitisSecondIFfunctionwillreturn2andINDEXfunctionwillchecktheFirstmonthifitis1andSecondmonthifitis2.
SoaftertheMATCHandIFfunctionisprocessedtheformulawilllooklikethis=INDEX(FirstandSecond,1,2,1)andyouwillgettheanswer250whichisArnoldearnedonthe13thday.
7.9.INDIRECTThisfunctioncreatesacellreferencefromavalidworksheetreference.
Syntax:
=INDIRECT(ref_text,[a1])
Parameterlist:
ref_text-Areferencesuppliedastext.
a1-[optional]aboolean(TRUEorFALSE)toindicateA1orR1C1-stylereference.DefaultisTRUE=A1style.
Pointstonote.
UseINDIRECTtocreateorsupplyareferenceintextform.Indirectisusefulwhenyouwanttoconvertatextvalueintoavalidcellreference.
ThereferencecreatedbyINDIRECTwillnotchangeevenwhencells,rows,orcolumnsareinsertedordeleted.Forexample,theformula=INDIRECT(“A1:A100”)willalwaysrefertothefirst100rowsofcolumnA,evenifrowsinthatrangearedeletedorinserted.
AlsoifyouwanttofindthesumofvaluesinthecellreferenceA1:A100andiftherowsareinsertedordeletedregularlythenyoucansettheformulalikethis=SUM(INDIRECT(“A1:A100”)),itwillalwaysgivethesumoftheA1toA100.Ifyoudirectlyputaformulalike=SUM(A1:A100)youwillgeterrormessageoncetherowsaredeleted.
Intheexamplefileexceltovba.com-INDIRECT.xls(sheetname:Result)wehaveusedtheformula=INDIRECT(D1&”!”&D2)toretrievethevaluefromothersheets.BychangingtheSheetnameandcellreferenceyouwillgetthevaluefromtherespectivesheets.
7.10.LOOKUPUsethisfunctionwhenyouneedtolookinasingleroworcolumnandfindavaluefromthesamepositioninasecondroworcolumn.TherearetwowaysforthisfunctionVectorformandArrayform
VectorForm
Usethisformtosearchoneroworonecolumnforavalue.Wewillelaborateusingexample.
Syntax:
LOOKUP(lookup_value,lookup_vector,[result_vector])
Parameterlist:
lookup_value-avaluethatLOOKUPsearchesforinthefirstvector.Itcanbeanumber,text,alogicalvalue,oranameorreferencethatreferstoavalue.IftheLOOKUPfunctioncan’tfindthelookup_valuethefunctionreturnsthevaluewhichislessthanorequalto
lookup_value.
lookup_vector-arangethatcontainsonlyoneroworonecolumn.Thevaluesinlookup_vectorcanbetext,numbers,orlogicalvalues.
result_vector[Optional]–arangethatcontainsonlyoneroworcolumn.Theresult_vectorargumentmustbethesamesizeaslookup_vector.Ithastobethesamesize.
Checktheexamplefileexceltovba.com-LOOKUP.xlsxSheet1
Inthisexamplefirstwearesearchingfor14.19incolumnAandifitmatchedwearegettingthevalueagainstcolumnBthatisinthesamerow.
Secondwearesearchingfor15.75incolumnAandsinceitisnotmatching,matchesthenearestsmallervalue(15.17),andreturnsthevaluefromcolumnBthatisinthesamerow.
Thirdwearesearchingfor17.66incolumnAandsinceitisnotmatching,matchesthenearestsmallervalue(16.39),andreturnsthevaluefromcolumnBthatisinthesamerow.
Looksup0incolumnA,andreturnsanerrorbecause0islessthanthesmallestvalue(14.14)incolumnA.
Pointstonote.
Thevaluesinlookup_vectormustbeplacedinascendingorder:…,-2,-1,0,1,2,…,A-Z,FALSE,TRUE;otherwise,LOOKUPmightnotreturnthecorrectvalue.
Lookupisnotcasesensitive,Uppercaseandlowercasetextareequivalent.
Iflookup_valueissmallerthanthesmallestvalueinlookup_vector,LOOKUPreturnsthe#N/Aerrorvalue.
Arrayform
ThisformofLOOKUPisprovidedforcompatibilitywithotherspreadsheetprograms,butitsfunctionalityislimited,insteadyoucanuseVLOOKUPorHLOOKUP.
ThearrayformofLOOKUPisverysimilartotheHLOOKUPandVLOOKUPfunctions.ThedifferenceisthatHLOOKUPsearchesforthevalueoflookup_valueinthefirstrow,VLOOKUPsearchesinthefirstcolumn,andLOOKUPsearchesaccordingtothedimensionsofarray.ThelimitationoftheLOOKUPfunctionisyouwillalwaysgetthe
lastvalueintheroworcolumn,youcannotgetthein-betweenvalues.
SoyoumustuseVLOOKUPorHLOOKUP.
7.11.MATCHThisfunctionsearchesforspecifiediteminarangeofcellsandreturnstherelativepositionofthatitemintherange.Forexample,iftherangeA1:A3containsthevalues8,39,and54,thentheformula
=MATCH(39,A1:A3,0)returnsthenumber2,39istheseconditemintherange.
Syntax:
=MATCH(lookup_value,lookup_array,[match_type])
Parameterlist:
lookup_value-thevaluetomatchinlookup_array.
lookup_array-arangeofcellsoranarrayreference.
match_type-[optional]Howtomatch,specifiedas-1,0,or1.Defaultis1.
Matchtypeinformation
Ifmatch_typeis1,MATCHfindsthelargestvaluethatislessthanorequaltolookup_value.Thelookup_arraymustbesortedinascendingorder.
Ifmatch_typeis0,MATCHfindsthefirstvalueexactlyequaltolookup_value.lookup_arraydoesnotneedtobesorted.
Ifmatch_typeis-1,MATCHfindsthesmallestvaluethatisgreaterthanorequaltolookup_value.Thelookup_arraymustbesortedindescendingorder.
Ifmatch_typeisomitted,itisassumedtobe1.
Pointstonote.
Matchisnotcase-sensitive.
Matchreturnsthe#N/Aerrorifnomatchisfound
Ifmatch_typeis0andlookup_valueistext,lookup_valuecancontainthewildcardcharactersasterisk(*)andquestionmark(?).Anasteriskmatchesanysequenceofcharacters;aquestionmarkmatchesanysinglecharacter.
Example1:
Checktheexamplefileexceltovba.com-MATCH.xlsxSheet1
InthisexamplefirstwearefindingoutthepositionofthenameMelvinfromthesefournamesasyoucanseeMelvinisinsecondpositionandwewillgettheansweras2andinthemarks50isin3rdpositionoutofthefourmarksmentionedsowewillgettheansweras3.
Example2:
Checktheexamplefileexceltovba.com-MATCH.xlsxSheet2usingmatch_type0
Inthisexamplefileweareusingmatch_type0asthirdparameterforexactmatchsoitisnotmandatorytosortthelistandthefunctionwillcheckonlyexactmatch,ifitisnotmatchedthe#NAerrorisreturned.
Youcanseetheascendinganddescendinglistgivestheexactmatch.
TheWrongValuelistcannotfindanexactmatch,sothe#NAerrorisreturned.
Example2:
Checktheexamplefileexceltovba.com-MATCH.xlsxSheet3usingmatch_type1
Inthisexamplefileweareusingmatch_type1asthirdparametertofindtheexactmatchorlessthanlookup_value.Ifyouareusingthematch_type1asthirdparameterthenthelistshouldbeascendingorderotherwiseitwillreturn#NAerror.
SotheAscendinglistgivestheexactmatchandtheDescendinglistgivesthe#NAerror.
TheWrongValuelistfindsthenextlowestnumberbecausethereisnoexactmatchforthevalue25andsincethelistisinascendingorderitwillfindnextlowestnumberwhichis20.
Example3:
Checktheexamplefileexceltovba.com-MATCH.xlsxSheet4usingmatch_type-1
Inthisexamplefileweareusingmatch_type-1asthirdparametertofindstheexactmatchorgreaterthanlookup_value.Thelistshouldbesortedindescendingorder
TheAscendinglistgivesthe#NAerror.
TheDescendinglistgivestheexactmatch.
TheWrongValuelistfindsthenexthighestnumberbutbecauseitinascendingorderitwillreturn#NAerror.
7.12.OFFSETThisfunctioncreatesareferenceoffsetfromgivenstartingpointandreturnsacellreference.Thestartingpointcanbeonecellorarangeofcells,andtheoffsetissuppliedasrowsorcolumns“offset”fromthestartingpoint.Theheightandwidthargumentsareoptionalanddeterminethesizeofthereferencethatiscreated.
Syntax:
=OFFSET(reference,rows,cols,[height],[width])
Parameterlist:
reference-thestartingpoint,suppliedasacellreferenceorrange.
rows-thenumberofrowstooffsetbelowthestartingreference.
cols-thenumberofcolumnstooffsettotherightofthestartingreference.
height-[optional]Theheightinrowsofthereturnedreference.
width-[optional]Thewidthincolumnsofthereturnedreference.
Checktheexamplefileexceltovba.com-OFFSET.xlsx
Inthisexamplefirstwearegettingthevalue18byoffsettingfromcellreferenceC1,3rowsdownand0column(samecolumn).
Likethatwearegettingthevalue74byoffsettingfromthecellB2,2rowsdownand2columnsright.
AndlastwearecalculatingthesumofthecellrangeD3:D5.FirstweareoffsettingfromA2cell1rowdownand3columnrighttoreachthecellreference.FourthandFifthparametersspecifytherowsandcolumnstoinclude.Fourthparameteris3soitwillinclude3rowsfromD3andonlyinclude1column(fifthparameteris1).
Pointstonote.
OFFSETcanbeusedtobuildadynamicnamedrangeforchartsorpivottables,tomakesurethatsourcedataisalwaysuptodate.
OFFSETonlyreturnsareference,nocellsormoved.
Bothrowsandcolscanbesuppliedasnegativenumberstoreversetheirnormaloffsetdirection-negativecolsoffsettotheleft,andnegativerowsoffsetabove.
OFFSETisa“volatile”formula;itisrecalculatedwheneverthereisanychangetoaworksheet.ItcanslowdownExcelinacomplicatedworksheet.
OFFSETwilldisplaythe#REF!errorvalueiftheoffsetisoutsidetheedgeoftheworksheet.
Whenheightorwidthisomitted,theheightandwidthofreferenceisused.
OFFSETcanbeusedwithanyotherfunctionthatexpectstoreceiveareference.
7.13.ROWThisfunctionreturnstherownumberofareference.Ifyouhavegivenacellrangethenitwillreturnthefirstcellrangerownumber.So=ROW(B2)willreturn2and=ROW(C2:C9)willalsoreturn2sinceitwillreturnonlythefirstrownumberoftherange.Ifyouentertheformulawithoutargumentslikethis=ROW()inacellitwillreturntherownumberoftheparticularcellyouhaveenteredthefunction.
Syntax:
=ROW([reference])
Parameterlist:
reference–[optional]areferencetoacellorrangeofcells.
7.14.ROWSThisfunctionreturnsthenumberofrowsinanarrayorreference.
Syntax:
=ROWS(array)
Parameterlist:
array-referencetoacellorrangeofcells.
UseROWStogettherowcountofareference.Forexample,theformula=ROWS(A1:A10)returnsthenumber10asthereare10rowsinthisrangefromA1toA10.
7.15.TRANSPOSEThisfunctionconvertsverticalrangeofcelltohorizontalandhorizontalrangeofcellstoverticalandreturnsanarrayinaneworientation.SincethisisanarrayfunctionyouhavetopressCtrl+Shift+Enterafterselectingandenteringthisformulatothecellsyouwantthenewvaluestobepasted.
Syntax:
=TRANSPOSE(array)
Parameterlist:
array-thearrayorrangeofcellstotranspose.
Thenewarraymustoccupythesamenumberofrowsasthesourcearrayhascolumns,andthesamenumberofcolumnsasthesourcearrayhasrows.
Checktheexamplefileexceltovba.com-OFFSET.xlsx
InthisexamplefirstwehavetoselectthecellrangeF1:J4(youshouldselectthe5columnsasthereare5rowstoconvertandyoushouldselect4rowsasthereare4columnstoconvert).
Entertheformula=TRANSPOSE(A1:D5)andpressCtrl+Shift+Entertoconverttoarrayformulaandthecolumnsandrowswillgettransposed.
7.16.VLOOKUPVlookupisoneoftheversatileandpowerfulformulasinExcelandisusedextensivelyforcomparingexcelsheets,dataextractingetc.VlookupmeansVerticallookup.Thisfunctionsearchesthevalueyouprovideinatableorcellranges(searchesinthetable’sfirstcolumn)andreturnsthevalueinthesamerowaccordingtothecolumnnumberyouspecify.
Syntax:
VLOOKUP(lookup_value,table_array,col_index_num,[range_lookup])
Parameterlist:
Lookup_value-thevaluetosearchfor,likeifyouwanttosearchthenameJohnisavailableinotherlistthenyouwillselectthecellwiththenameJohn.
table_array-wherewearegoingtosearch,itwilldefinitelybeagroupofcellsortableinsamesheetorothersheetorotherworkbook.
col_index_num-thecolumnnumberinthetablefromwhichtoretrieveavalue.
range_lookup-[optional]TRUE=approximatematch(default).FALSE=exactmatch.
Rightnowtheparameterslooksconfusingbutdon’tworryonceIexplainusingexamplesyouwillfinditveryeasy.
VlookupusingtherangelookupFALSE.
Example1:
Checktheexamplefileexceltovba.com-VLOOKUP1.xlsx
InthisexamplewewanttofindthemarksearnedbyeachStudents.
FirstwearegoingtosearchthenameJohninthecellrangeC7:F10,sofirstweenterthenameJohnasfirstparameterindoublequotesaswearesearchingatext,andsecondparameterweareenteringthecellrangeC7:F10wherewearegoingtosearch.
ThirdparameterwearespecifyingthecolumnindexnumberfromthecellrangeC7:F10sincethestartingcolumnisCitisthefirstcolumnnumber,Dthesecondcolumnnumber,EthethirdoneandFthefourthone.Andfourthparameterweareputting0orFalsetogetanexactmatch.
ThepointtobenotedhereisthecellrangeC7:F10theCcolumn(firstcolumn)musthavethevalueJohnwhatwearesearching,thenonlyVLOOKUPwillworkotherwiseitwillgivea#N/Aerror.
Inthisexamplewearehardcodingthevaluewearesearchingandthisisnotandefficientway.SowewillmakesomechangetomakethelifeeasierinthesecondExample.
Pointstonote.
VLOOKUPonlylooksfromlefttotheright,inthiscaseiftheNamecolumn(C)comesaftertheChemistrycolumn(F)thenthisfunctionwon’twork,eitheryouhavetocopythenamecolumntothelefthandsideoryoucanusethefunctionsINDEXandMATCHclubbedtogethertoovercomethislimitation.
VLOOKUPwillalwayslookforthefirstmatchonly.IftherearetwopersonswithsamenamethenVLOOKUPwillretrievethefirstvalueonly.IntheaboveexampleifthereisonemorepersonwhosenameisJohnthenyouwon’tbeabletoretrievethedataofthat
person.
VLOOKUPisnotcasesensitive,thenameJohnorJOHNorJoHnistreatedassame.
IfyouchangethecellrangebyinsertingordeletingthecolumnsthentheVLOOKUPvaluewillgivewronganswer.IntheaboveexampleifyoudeletethePhysicscolumnthenMathscolumnwillbecomethesecondcolumnandyouwillgetawronganswer.
Sometimesdatayouseewilllooklikeanumberbutitmaybeformattedastext.InthiscaseyouhavechangethetexttonumberusingtheVALUEfunction.
Youwillget#N/Aerrorifthedatayouaresearchingisnotthere.IfthenameJohnisnottherethenyouwillgetthiserror.
Alsoifyouenterthewrongcol_index_numyouwillgetoutofreferenceerrorlikethis#REF!.Intheaboveexampleifyouenter7asthethirdparameteryouwillgetthiserrorasthereareonlyfourcolumnstoretrievedata.
BeforewritingtheVlookupformulayoumustcheckthedatacolumnsyouarecomparingdoesnotcontainanyleadingandtrailingspaceasthiswillgivewrongresultsasthedatayouareseeingandactualdatamaybeofdifferentlength.SayifthenameyouareseeingisJohnbutthedatalengthmaybefivebecauseofthetrailingorleadingspace.Insuchcasesyouhavetousethetrimfunctiontoeliminatethesespaces.
Example2:
Checktheexamplefileexceltovba.com-VLOOKUP2.xlsx
InthisexampleinsteadofhardcodingthefirstandthirdparameterswearesupplyingthesameascellreferencesE7andE8sothatyoucanchangethenameandthecolumnnumberintherespectivecellstogettheresultseasily.AlsoifyouwantyoucangiveanametothecellrangelikeMarksorTotalmarkssotheformulawillbeeasytoreadlikethis=VLOOKUP(F7,Marks,F8,0).
Example3:
ClubbingVLOOKUPwithMATCHforafullydynamiccolumnindex
Checktheexamplefileexceltovba.com-VLOOKUP3.xlsx
InthisexamplefileweareclubbingVLOOKUPwithMATCHtocreateadynamicVLOOKUPsothatwecancomparedataverticallyandhorizontallyinasinglego.InthefirstandsecondparameteroftheVLOOKUPwearecheckingthesparepartnameisavailableinCostTableandifitistherewewillfetchthedataaccordingtothecolumnnumberderivedfromMATCHfunction.
AsthirdparameterweareenteringtheMATCHfunctionlikethisMATCH(A2,$B$16:$F$16,0)+1.Whatthismeansiswearematchingthecompanynameandifitmatchesthecostwillbepickedfromtheparticularcolumnandinordertogivetheexactcolumnnameweshouldadd1tomatchvaluetogivetheVLOOKUPthecorrectcolumnnumberasVLOOKUPstartscomparingfromCOLUMNA.
HereweareaddingthedollarsigninthesecondandthirdparameterinordertolockthecellrangewearelookingsothatwhenyoucopydowntheformulaVLOOKUPwillstillsearchthesameCosttable.
VlookupwithRange_lookupTrue
AnothergreatuseofVlookupistoautomaticallycategorizethedataaccordingtoyourspecification.Sayifyouwanttoawardgradestothestudentsintheschoolaccordingtothemarkstheyearnedorifyouwanttocategorizethesalespersonaccordingtotheirperformanceyoucanmakeuseofthisproperty.
Example4:
Checktheexamplefileexceltovba.com-VLOOKUP4.xlsx
InthisfilewearefindingoutstudentsGradesaccordingtotheGradeCriteriayouhavecreated.ThemainthingtorememberisthefirstcolumnoftheGradeCriteriashouldbein
ascendingorderotherwiseitwillgivewrongresultsandFcolumnisaddedforyoutoseetheGradesvisuallyandisnotrequiredforcalculation.
Formulaused=VLOOKUP(B2,$E$2:$G$7,3,TRUE)
FirstwearecomparingBcolumnwiththeEcolumnandthengetthecorrespondingrowvalueintheGColumn.SofirstwecomparetheJohn’smark,theVLOOKUPwillcheckwhetherthevalue99isthereintheGradescriteriacolumnEandifitdoesn’tfinditwillfallbacktothenextvaluewhichis90andsincewehavegiventhethirdparameteras3itwillpickfromthethirdcolumnwhichisA.
LikewiseforArnolditwillcheck58isthere,ifitisnotthereitwillfallbacktothenextvaluewhichis50andwewillgettheGradeEandifyoucopythewholeformuladownyouwillgetthegradesforallstudents.
Pointstonote.
WehaveusedTRUEasthefourthparameter,youcanuse1insteadorelseyoucanomitthisbecausebydefaultthefourthparameterisTRUE.
Asyoucanseeinthesecondparameterwehaveuseddollarsignin-betweenthecellreference,thisisusedtochangethecellreferencefromrelativetoabsolute.InotherwordsthisisusedforlockingthecellssothatwhenyoucopydowntheVLOOKUPformulaitshouldalwayssearchinsidethecellrangeE3toG8.Trycopyingdownwithoutthedollarsignandseewhathappens.
IftheGradesCriteriaisinseparateworkbookthenyoudon’thavetoputtheDollarsignitwillautomaticallyinsertedintotheformulaotherwiseyoucanmanuallyenterbyhittingtheF4keyafterenteringthesecondcriteria.
HowtohandletheErrors
SayifyouwanttoVLOOKUPthedataandbasedontheVLOOKUPdatayouwantto
performsomecalculations.InthefirstexampleifJohnisnottherethenwewillget#N/AErrorandwhatevercalculationsyouaregoingtodowillgowrong.
InthiscaseyoushouldgoforonemoreerrorcheckingfunctionISNAfunction.Itbasicallytests#N/AErrorandreturnsTRUE,otherwisethefunctionreturnsFALSE.SoIwilladdonemorelayertothefirstVLOOKUPformula,beforetheVLOOKUPwewilladdISNAlikethis.
=ISNA(VLOOKUP(A2,Sheet2!$B$2:$C$9,2,0))
SothisfunctionwillreturnTrueif#N/AErroristhereandFalseifnot.Butstillifyouwanttodosomecalculationsitwon’tbeofanyuseifwegettheanswerasTrueorFalse.SoIamaddingonemorelayerifthevalueisthereweshouldgetthevalueotherwiseweshouldget0.ForthatyoucanusetheIFformula.Hopeyouremembertheformula.
If(logicaltest,valueiftrue,valueifwrong)
Inthefirstparameterwewillputtheformula
=ISNA(VLOOKUP(A2,Sheet2!$B$2:$C$9,2,0))
andifthisistruethenweshouldget0sowewillput0assecondparameterandinthethirdparameteragainwewillwritethesameVlookupformulawithoutISNAfunctionlikethisVLOOKUP(A2,Sheet2!$B$2:$C$9,2,0)sothatyoushouldgettheanswerifthevalueispresent.Soifyoucluballthreeparameterstheformulawilllooklikethis.
=IF(ISNA(VLOOKUP(A2,Sheet2!$B$2:$C$9,2,0)),0,(VLOOKUP(A2,Sheet2!$B$2:$C$9,2,0)))
PointstoconsiderwhenusingVLOOKUP.
VLOOKUPcannotlookuptotheleftofthecolumn,ifthedatayouarelookingisontheleftsideofthetableyouarelookingthenyouwon’tbeabletogetthedetails.
AlsoifyouaredoingVLOOKUPforlargechunksofdatathenitwillslowdowntheExcelconsiderably.InthiscaseyoucanusetheINDEXandMATCHfunctionclubbedtogethertobehavelikeVLOOKUPfunction.
8.MathandTrigonometry8.1.ABSThisfunctionsreturnstheabsolutevalueofanumber.
Syntax:
ABS(number)
Parameterlist:
number-therealnumberofwhichyouwanttheabsolutevalue.
Asyoucanseeitremovesallthenegativesignfromthenumbersasintheexamplegivenbelow.
Checktheexamplefileexceltovba.com-ABS.xls
Pleaseopensheet2inthesameexamplefileandherewearefindingthetotalofallthevaluesinBcolumnirrespectiveofthesignbeitpositiveornegative.
o
HereyoucanseeintheB10cellwehavecalculatedthetotalsum,SUMfunctionwilladjustthepositiveandnegativevaluesyouwillgetthedifferenceofpositiveandnegativevalues.Butifyouwanttogetthetotalofallirrespectiveofthesignthenwewillusethisformula=SUM(ABS(B2:B8))andpressCtrl+Shift+Entersothatthisformulawillbechangedtoarrayformulalikethis{=SUM(ABS(B2:B8))}andyouwillgettheSUMofallthevaluesirrespectiveofthesign.
WhatthisformuladoesisitwillcreateanarrayinthememorywithabsolutevaluesandthenaddupallthevaluestogivebacktheSUM.
Ifyoudon’twanttousearrayformulayoucanusetheformulalikethis=SUMPRODUCT(ABS(B2:B9)).SUMPRODUCTusuallymultipliesthearraysandwillmakeatotalofthemultipliedvalues.SinceherethereisonlyonearrayB2:B9SUMPRODUCTfunctionwilljustaddupallthevalueafterconvertingtoabsolutevaluesandyouwillgetthetotalofthesame.
8.2.AGGREGATEThisisanewfunctionintroducedinExcel2010andisveryversatilefunction,somanyfunctionsclubbedtogethertothissinglefunction.TheaggregatefunctioncanbeusedasSUM,COUNT,MIN,AVERAGEdependsuponthefunction_numyouspecify.=AGGREGATE(9,0,A1:A2)willfindtheSUMofthecellsA1andA2,=AGGREGATE(1,0,A1:A2)willfindtheAVERAGEofthecellsA1andA2.
TherearetwoformsforthisfunctionReferenceformandArrayform
REFERENCEFORM
Syntax:
AGGREGATE(function_num,options,ref1,[ref2],…)
function_num-anumber1through13tospecifythefunction,asshowninthefunction_numTablebelow.
options-anumberthatdetermineswhichvaluestoignoreintheevaluationrangeforthefunction,asshownintheoptionsTablebelow.
ref1-thefirstreferenceornumericargumentforwhichyouwanttheaggregatevalue.
ref2[Optional].referencesornumericarguments2to253forwhichyouwanttheaggregatevalue.
ARRAYFORM
Syntax:
AGGREGATE(function_num,options,array,[k])
function_num-anumberfrom14to19thatspecifieswhichfunction,asshowninthefunction_numTablebelow.
options-anumberthatdetermineswhichvaluestoignoreintheevaluationrangeforthefunction,asshownintheOptionsTablebelow.
array-anarray,anarrayformula,orareferencetoarangeofcellsforwhichyouwanttheaggregatevalue.
k-eachofthesixArray-Formfunctions(LARGE,SMALL,PERCENTILE.INC,QUARTILE.INC,PERCENTILE.EXCandQUARTILE.EXCrequiresasecondargument.
Pointstonote.
Thefunctionwillnotignorehiddenrows,nestedsubtotalsornestedaggregatesifthearrayargumentincludesacalculation,forexample:=AGGREGATE(14,3,A1:A10*(A1:A10>0),1)
Ifasecondrefargumentisrequiredbutnotprovided,AGGREGATEreturnsa#VALUE!error.
Ifoneormoreofthereferencesare3-Dreferences,AGGREGATEreturnsthe#VALUE!errorvalue.
TheAGGREGATEfunctionisdesignedforcolumnsofdata,orverticalranges.
Function_numTable
Function_numFunction––––––-SyntaxForm
1––––––-AVERAGEReference
2––––––-COUNTReference
3––––––-COUNTAReference
4––––––-MAXReference
5––––––-MINReference
6––––––-PRODUCTReference
7––––––-STDEV.SReference
8––––––-STDEV.PReference
9––––––-SUMReference
10–––––—VAR.SReference
11–––––—VAR.PReference
12–––––—MEDIANReference
13–––––—MODE.SNGLReference
14–––––—LARGEArray
15–––––—SMALLArray
16–––––—PERCENTILE.INC–––-Array
17–––––—QUARTILE.INCArray
18–––––—PERCENTILE.EXCArray
19–––––—QUARTILE.EXCArray
SecondparameterOptionsisanumericalvaluethatdetermineswhichvaluestoignorefromtherangeyouspecify.Detailsoftheoptionnumberandtheirbehaviorgivenbelow.
OptionsTable
OptionBehavior
0oromittedIgnorenestedSUBTOTALandAGGREGATEfunctions
1Ignorehiddenrows,nestedSUBTOTALandAGGREGATEfunctions
2Ignoreerrorvalues,nestedSUBTOTALandAGGREGATEfunctions
3Ignorehiddenrows,errorvalues,nestedSUBTOTALandAGGREGATEfunctions
4Ignorenothing
5Ignorehiddenrows
6Ignoreerrorvalues
7Ignorehiddenrowsanderrorvalues
Checktheexamplefileexceltovba.com-AGGREGATE.xlsx
Inthisexamplewearefirstcalculatingthemaximumvaluewhileignoringerrorvaluesintherange.=AGGREGATE(4,6,A2:A12).Firstparameterinthisfunctionis6sothisfunctionwillcalculateMAXvaluewhileignoringtheerrorvalueswhichisspecifiedinthesecondparameteras6fromtherangesupplied.
Secondwearecalculatingthemedianwhileignoringerrorvaluesintherange.
Andthelastthreeweareusingthearrayform.
Thirdwearegettinga#VALUE!errorbecauseAGGREGATEisexpecting(functionSMALL)asecondrefargument,itisanarrayform,soyoushouldprovidethefourthparameter.
Fourthonecalculatesthe2ndsmallestitemwhileignoringerrorvaluesintherange.
Fifthonecalculatesthe3rdlargestvaluewhileignoringerrorvaluesintherange.
8.3.CEILINGThisfunctionroundsanumberupawayfromzerotothenearestspecifiedmultipleandreturnvaluewillbearoundednumber.
Syntax:
=CEILING(number,significance)
Parameterlist:
number-thenumberyouwanttoround.
significance-themultipletowhichyouwanttoround.
Pointstonote.
Ifeitherargumentisnonnumeric,CEILINGreturnsthe#VALUE!errorvalue.
Regardlessofthesignofnumber,avalueisroundedupwhenadjustedawayfromzero.Ifnumberisanexactmultipleofsignificance,noroundingoccurs.
Ifnumberisnegative,andsignificanceisnegative,thevalueisroundeddown,awayfromzero.
Ifnumberisnegative,andsignificanceispositive,thevalueisroundeduptowardszero.
Examples:
=CEILING(5.5,1)Rounds5.5uptonearestmultipleof1whichis6.
=CEILING(-5.5,-2)Rounds-5.5uptonearestmultipleof-2whichis-6.
=CEILING(-5.5,2)Rounds-5.5uptonearestmultipleof2whichis-4.
=CEILING(6.5,0.1)Rounds6.5uptothenearestmultipleof0.1whichis6.5.
=CEILING(0.586,0.01)Rounds0.586uptothenearestmultipleof0.01whichis0.59.
8.4.CEILING.PRECISEThisfunctionreturnsanumberthatisroundeduptothenearestintegerortothenearestmultipleofsignificance.Regardlessofthesignofthenumber,thenumberisroundedupandifthenumberorthesignificanceiszero,zeroisreturned.
Syntax::
CEILING.PRECISE(number,[significance])
Parameterlist:
number-thevaluetoberounded.
Significance[optional]-themultipletowhichnumberistoberounded.Ifsignificanceisomitted,itsdefaultvalueis1.
Examples:
=CEILING.PRECISE(8.3)Rounds8.3uptothenearestmultipleof1whichis9.
=CEILING.PRECISE(-8.3)Rounds-8.3uptothenearestmultipleof1,roundstoward0becausethenumberisnegativeandwewillgettheanswer-8.
=CEILING.PRECISE(8.3,2)Rounds8.3uptothenearestmultipleof2whichis10.
=CEILING.PRECISE(8.3,-2)Rounds8.3uptothenearestmultipleof-2whichis10.
=CEILING.PRECISE(-8.3,2)Rounds-8.3uptothenearestmultipleof2,roundstoward0becausethenumberisnegativeandwewillgettheanswer-8.
=CEILING.PRECISE(-8.3,-2)Rounds-8.3uptothenearestmultipleof-2andwewillget-8.
8.5.COMBINThisfunctionreturnsthenumberofcombinationsforagivennumberofitems.
Syntax:
COMBIN(number,number_chosen)
Parameterlist:
number-thenumberofitems.
number_chosen-thenumberofitemsineachcombination.
Forexample=COMBIN(6,2)wewillgettheansweras15asthereare15combinationswecanmakewithouttheduplicateentry.Forany6objects(eg.p,q,r,s,t,u)thereare15differentcombinationsof2objects.Theseare:pq,pr,ps,pt,pu,qr,qs,qt,qu,rs,rt,ru,st,su,tu.
Pointstonote.
IfeitherargumentNumberorNumber_chosenisnonnumeric,COMBINreturnsthe#VALUE!errorvalue.
Ifnumber<0ornumber_chosen<0ornumber<number_chosenCOMBINreturnsthe#NUM!errorvalue.
8.6.EVENThisfunctionroundsanumberuptothenextevenintegerandreturnsaneveninteger.
Syntax:
=EVEN(number)
Parameterlist:
number-thenumbertorounduptoaneveninteger.
Pointstonote.
Ifnumberisnonnumeric,EVENreturnsthe#VALUE!errorvalue.
Thenegativenumbersarerounded“up”awayfromzero,sotheyactuallybecomemorenegative.
Examples:
=EVEN(4.5)Rounds4.5tothenearesteveninteger6.
=EVEN(5)Rounds5tothenearesteveninteger6.
=EVEN(4)Rounds4tothenearesteveninteger4.
=EVEN(-3)Rounds-3tothenearesteveninteger-4.
8.7.EXPThisfunctionfindsthevalueoferaisedtothepowerofanumber.Theconstanteequals2.71828182845904,thebaseofthenaturallogarithm.
Syntax:
=EXP(number)
Parameterlist:
number-thepowerthateisraisedto.
Examples:
=EXP(1)wewillgettheapproximatevalueofewhichis2.71828183
=EXP(2)wewillgetthebaseofthenaturallogarithmeraisedtothepowerof2whichis7.3890561.
8.8.FACTThisfunctionfindsthefactorialofanumber.Thefactorialofanumberisequalto
1*2*…*number.Forexamplefactorialof4is1x2x3x4whichis24.
Syntax:
=FACT(number)
Parameterlist:
number-thenumbertogetthefactorialof.
Pointstonote.
Thenumbermustnotbenegativeoryouwillgetanerrorvalue.
Ifthenumberisnotanintegeritwillbetruncated.
Examples:
=FACT(4)Factorialof4,or1*2*3*4is24.
=FACT(2.9)Factorialoftheintegerof2.9is2.
=FACT(0)Factorialof0is1.
=FACT(-5)Factorialofanegativenumberreturnsanerrorvalue#NUM!.
=FACT(1)Factorialof1is1.
8.9.FACTDOUBLEThisfunctionreturnsthedoublefactorialofanumber.
Syntax:
FACTDOUBLE(number)
Parameterlist:
number-thevalueforwhichtoreturnthedoublefactorial.Ifnumberisnotaninteger,itistruncated.
Pointstonote.
Ifnumberisnonnumeric,FACTDOUBLEreturnsthe#VALUE!errorvalue.
Ifnumberisnegative,FACTDOUBLEreturnsthe#NUM!errorvalue.
Ifnumberisevenitwillmultiplyalltheevennumberstothenumber.
Ifnumberisodditwillmultiplyalltheoddnumberstothenumber.
Examples:
=FACTDOUBLE(4)because4isanevennumberthedoublefactorialisequivalentto4*2andwewillget8astheanswer.
=FACTDOUBLE(6)because6isanevennumberthedoublefactorialisequivalentto6*4*2andwewillget48astheanswer
=FACTDOUBLE(5)because5isanoddnumberthedoublefactorialisequivalentto5*3
andwewillget15astheanswer.
=FACTDOUBLE(7)because7isanoddnumberthedoublefactorialisequivalentto7*5*3andwewillget105astheanswer.
8.10.FLOORThisfunctionwillroundanumberdowntothenearestspecifiedmultipleandreturnsaroundednumber.
Syntax:
=FLOOR(number,multiple)
Parameterlist:
number-thenumberthatshouldberounded.
multiple-themultipletousewhenrounding.
Pointstonote.
Ifeitheroftheparametersisnonnumeric,FLOORreturnsthe#VALUE!errorvalue.
Ifnumberispositiveandsignificanceisnegative,FLOORreturnsthe#NUM!errorvalue.
Ifthesignofnumberisnegativethevalueisroundeddownandadjustedawayfromzero.Ifnumberisanexactmultipleofsignificance,noroundingoccurs.
Examples:
=FLOOR(5.7,2)Rounds5.7downtonearestmultipleof2whichis4.
=FLOOR(-5.5,-2)Rounds-5.5downtonearestmultipleof-2whichis-4.
=FLOOR(2.5,-2)Returnsanerrorvalue,because2.5and-2havedifferentsigns#NUM!.
=FLOOR(2.58,0.1)Rounds2.58downtothenearestmultipleof0.1whichis2.5.
=FLOOR(0.334,0.01)Rounds0.334downtothenearestmultipleof0.01whichis0.33.
8.11.FLOOR.PRECISEThisfunctionreturnsanumberthatisroundeddowntothenearestintegerortothenearestmultipleofsignificance.Itignoresthesignofthenumberandthenumberisroundeddown.However,ifthenumberorthesignificanceiszero,zeroisreturned.
Syntax:
FLOOR.PRECISE(number,[significance])
Parameterlist:
number-thevaluetoberounded.
significance[optional]themultipletowhichnumberistoberounded.Ifsignificanceisomitted,itsdefaultvalueis1.
Examples:
=FLOOR.PRECISE(-6.2,-1)rounds-6.2downtothenearestmultipleof-1to-7.
=FLOOR.PRECISE(6.2,1)rounds6.2downtothenearestmultipleof1to6.
=FLOOR.PRECISE(-6.2,1)rounds-6.2downtothenearestmultipleof1to-7.
=FLOOR.PRECISE(6.2,-1)rounds6.2downtothenearestmultipleof-1to6.
=FLOOR.PRECISE(6.2)rounds6.2downtonearestmultipleof1to6.
8.12.GCDThisfunctionreturnsthegreatestcommondivisoroftwoormorenumbers.Thegreatestcommondivisoristhelargestintegerthatdividesbothnumber1andnumber2withoutaremainder.
Syntax:
=GCD(number1,[number2],…)
Parameterlist:
number1-thefirstnumber.
number2-[optional]thesecondnumber.
TheGCDfunctioncanacceptupto255numbersasarguments.
Examples:
=GCD(7,2)Greatestcommondivisorof7and2is1.
=GCD(36,44)Greatestcommondivisorof36and44is4.
=GCD(7,1)Greatestcommondivisorof7and1is1.
=GCD(7,0)Greatestcommondivisorof7and0is7.
8.13.INTThisfunctionroundsthenumbertotheintegerbyroundingdown.Forexample,INT(8.99)returnsthenumber8andINT(-9.8)willgiveyoumorenegativenumber-10asINTfunctionwillalwaysrounddown.
Syntax:
=INT(number)
Parameterlist:
number-thenumberfromwhichyouwantaninteger.
TRUNCandINTaresimilarfunctions.TRUNCremovesthefractionalpartofthenumber.INTroundsnumbersdowntothenearestintegerbasedonthevalueofthefractionalpartofthenumber.INTandTRUNCaredifferentonlywhenusingnegativenumbers;TRUNC(-8.3)returns-8butINT(-8.3)returns-9because-9isthelowestnumber.
8.14.LCMThisfunctionreturnstheleastcommonmultipleofthenumberornumbers.
Syntax:
=LCM(number1,[number2],…)
Parameterlist:
number1-thefirstnumber.
number2-[optional]thesecondnumber.
UsetheLCMfunctionwhenyouwanttocalculatetheleastcommonmultipleofintegers.Theleastcommonmultipleisthesmallestpositiveintegerthatisamultipleofallofthenumberssuppliedasarguments.
Forexample,=LCM(3,4)returns12,since12isthesmallestmultipleofboth3and4.However,=LCM(3,4,5)returns60,since60isthesmallestmultipleofallthreenumbers.
Pointstonote.
Ifanyargumentisnonnumeric,LCMreturnsthe#VALUE!errorvalue.
Ifanyargumentislessthanzero,LCMreturnsthe#NUM!errorvalue.
8.15.MODThisfunctionreturnstheremainderfromdivision.
Syntax:
=MOD(number,divisor)
Parameterlist:
number-thenumberforwhichyouwanttofindtheremainder.
divisor-thenumberbywhichyouwanttodividenumber.
=MOD(16,4)youwillget0asreminderas16iscompletelydivisibleby4.
=MOD(35,3)youwillget2,3x11is33andthedifferencebetween35and33is2.
8.16.MROUND
Thisfunctionwillroundanumbertothenearestspecifiedmultiple.MROUNDroundsup,awayfromzero.Theroundinghappenswhendividingnumberbymultipleisgreaterthanorequaltohalfthevalueofmultiple.
Syntax:
=MROUND(number,multiple)
Parameterlist:
number-Thenumberthatshouldberounded.
multiple-Themultipletousewhenrounding.
=MROUND(11,3)Rounds11tothenearestmultipleof3whichis12.
=MROUND(-7,-3)Rounds-7tothenearestmultipleof-3whichis-6.
=MROUND(2.3,0.2)Rounds2.3tothenearestmultipleof0.2whichis2.4.
=MROUND(10,-3)Returnsthe#NUM!errormessagebecause-3and10havedifferentsignsandwillget#NUM!
8.17.ODDThisfunctionroundanumberuptothenearestoddinteger.
Syntax:
=ODD(number)
Parameterlist:
number-Thenumbertorounduptoanoddinteger.
Pointstonote.
Negativenumbersarerounded“up”,awayfromzero,sotheywillbecomemorenegative.
Ifthenumberisnonnumeric,ODDreturnsthe#VALUE!errorvalue.
Examples:
=ODD(3.5)Rounds3.5uptothenearestoddinteger5.
=ODD(5)Rounds5uptothenearestoddinteger5.
=ODD(4)Rounds4uptothenearestoddinteger5.
=ODD(-3)Rounds-3uptothenearestoddinteger-3.
=ODD(-4)Rounds-4up(awayfrom0)tothenearestoddinteger-5.
8.18.PIThisfunctionreturnsthemathematicalconstantpi,3.14159265358979.
Syntax:
=PI()
ThereisnoargumentsforPI.
Examples:
=PI()Returnspi3.141592654.
=PI()/3Returnspidividedby3gives1.047197551.
=PI()*(A1^2)AreaofacirclewiththeradiusdescribedinA1(cellA1valueis4)gives50.26548246.
8.19.POWERThisfunctionreturnstheresultofanumberraisedtoapower.
Syntax:
POWER(number,power)
Parameterlist:
number-thebasenumber.Itcanbeanyrealnumber.
power-theexponenttowhichthebasenumberisraised.
Examples:
=POWER(4,2)4squaredmeans4x4willget16.
=POWER(4,3)means4x4x4willget64.
=POWER(58.3,4.1)58.3raisedtothepowerof4.1willget17347666.9011973.
=POWER(4,6/5)4raisedtothepowerof6/5willget5.27803164309158.
8.20.PRODUCTThisfunctionmultipliesallthenumbersgivenasargumentsandreturnstheproduct.=Product(A1,A2)willmultiplythetwonumbersinthecellA1andA2.
Syntax:
PRODUCT(number1,[number2],…)
Parameterlist:
number1-thefirstnumberorrangethatyouwanttomultiply.
number2[optional].additionalnumbersorrangesthatyouwanttomultiply,uptoamaximumof255arguments.
Pointstonote.
Ifanargumentisanarrayorreference,onlynumbersinthearrayorreferencearemultiplied.Emptycells,logicalvalues,andtextinthearrayorreferenceareignored.
Examples:
=PRODUCT(A1:A5)willmultiplythevaluesinA1toA5andreturnthePRODUCT.ItislikemultiplyingA1xA2XA3XA4XA5.
8.21.QUOTIENTThisfunctionreturnstheintegerportionofadivisionanddiscardthereminder.ForExample=QUOTIENT(5,2)wewillget2astheansweras2x2isfourandtheremainder1isdiscarded.=QUOTIENT(7,2)willgivetheanswer3as2x3is6andthebalance1isdiscarded.
Syntax:
QUOTIENT(numerator,denominator)
Pointstonote.
numerator–thedividend.
denominator-thedivisor.
Ifeitherargumentisnonnumeric,QUOTIENTreturnsthe#VALUE!errorvalue.
Examples:
=QUOTIENT(7,2)Integerportionof7/2is3.
=QUOTIENT(9,2)Integerportionof9/2is4.
=QUOTIENT(5.5,4.1)Integerportionof4.5/3.1is1.
=QUOTIENT(-13,4)Integerportionof-10/3is-3.
8.22.RANDThisfunctionwillreturnarandomnumberbetween0and1andthereisnoargumentforthisfunction.Eachtimethepageisrefreshedorthefunctionisuseditwillgeneratedifferentvalues.
Syntax:
RAND()
Ifyoudon’twanttherandomnumberstobegeneratedyouhavetocopythecellandpasteitasvaluesusingpastespecial.
Orelseifyouwantgetarandomnumberthatdoesn’tchangewhentheworksheetiscalculated,enter=RAND()intheformulasbarandthenpressF9toconverttheformulaintoitsresult.
Alsotogenerateasetofrandomnumbersinmultiplecells,selectthecells,enterRAND()andpressControl+enter.
Togeneratearandomnumberbetweenaandb,usethisformula:RAND()*(b-a)+a.
8.23.RANDBETWEENThisfunctionwillreturnarandomintegerbetweentwovaluesyousupply.Forexample,=RANDBETWEEN(1,50)mightgeneratethenumber38RANDBETWEENcalculatesanewvalueeachtimetheworksheetiscalculated.
Syntax:
=RANDBETWEEN(bottom,top)
Parameterlist:
bottom-anintegerrepresentingthelowervalueoftherange.
top-anintegerrepresentingthelowervalueoftherange.
Tostoprandomnumbersfrombeingupdated,copythecellsthatcontainRANDBETWEENandpasteitasvaluesusingpastespecial.Togenerateasetofrandomintegersinmultiplecells,selectthecells,entertheRANDBETWEENfunction,andpressControl+Enter.
Togetarandomnumberthatdoesn’tchangewhentheworksheetiscalculated,enterRANDBETWEENintheformulasbarandthenpressF9toconverttheformulaintoitsresult.
8.24.ROMANThisfunctionconvertsanArabicnumeraltoRoman,astext.
Syntax:
ROMAN(number,[form])
Parameterlist:
number-theArabicnumeralyouwantconverted.
form-anumberspecifyingthetypeofromannumeralyouwant.Theromannumeralstyle
rangesfromClassictoSimplified,becomingmoreconciseasthevalueofformincreases.
FormType
0oromittedClassic.
1Moreconcise.Seeexamplebelow.
2Moreconcise.Seeexamplebelow.
3Moreconcise.Seeexamplebelow.
4Simplified.
TRUEClassic.
FALSESimplified.
Pointstonote.
Ifnumberisnegative,the#VALUE!errorvalueisreturned.
Ifnumberisgreaterthan3999,the#VALUE!errorvalueisreturned.
Examples:
=ROMAN(599,0)Classicromannumeralstylefor599whichisDXCIX.
=ROMAN(599,1)Moreconciseversionfor599whichisDVCIV.
=ROMAN(599,2)Moreconciseversionfor599whichisDIC.
=ROMAN(599,3)Moreconciseversionfor599whichisDIC.
=ROMAN(599,4)Simplifiedversionfor599whichisDIC.
8.25.ROUNDThisfunctionroundsanumbertoagivennumberofdigits.=ROUND(45.2564,2)willgiveyou45.25,roundedtotwodecimalplaces.
Syntax:
=ROUND(number,num_digits)
Parameterlist:
number-thenumbertoround.
num_digits-thenumberofdigitstowhichnumbershouldberounded.
Pointstonote.
Roundworksbyroundingnumbers1-4down,androundingnumbers5-9up.
TheROUNDfunctionroundsnumberstoaspecifiedlevelofprecision.Itcanroundtotherightorleftofthedecimalpoint.
Ifnum_digits>0,numberisroundedtothespecifiednumberofdecimalplacestotherightofthedecimalpoint.
Ifnum_digits<0,numberisroundedtotheleftofthedecimalpoint(i.e.tothenearest10,100,1000,etc.).
Ifnum_digits=0,numberisroundedtothenearestinteger.
Examples:
=ROUND(32.85,1)Rounds32.85toonedecimalplaceas32.9.
=ROUND(4.859,1)Rounds4.859toonedecimalplaceas4.9.
=ROUND(-8.965,2)Rounds-8.965totwodecimalplacesas-8.97.
=ROUND(31.5,-1)Rounds31.5toonedecimalplacetotheleftofthedecimalpointto30.
=ROUND(546.3,-3)Rounds546.3tothreedecimalplacetotheleftofthedecimalpointto1000.
=ROUND(1.14,-1)Rounds1.14tothenearestmultipleof10,whichis0.
=ROUND(-60.55,-2)Rounds-60.55tothenearestmultipleof100whichis-100.
8.26.ROUNDDOWNThisfunctionroundsanumberdowntoagivennumberofdigitstowardszero.
Syntax:
=ROUNDDOWN(number,num_digits)
Parameterlist:
number-thenumbertorounddown.
num_digits-thenumberofdigitstowhichnumbershouldberoundeddown.
TheROUNDDOWNfunctionworksliketheROUNDfunctionexceptthatwhenrounding,theROUNDDOWNfunctionwillalwaysroundthenumbers1-9down.
TheROUNDDOWNfunctioncanroundeithertotheleftorrightofthedecimalpoint.
Ifnum_digits>0,numberisroundeddowntothespecifiednumberofdecimalplacestotherightofthedecimalpoint.
Ifnum_digits<0,numberisroundeddowntotheleftofthedecimalpoint(i.e.tothenearest10,100,1000,etc.).
Ifnum_digits=0,numberisroundeddowntothenearestinteger.
Examples:
=ROUNDDOWN(4.2,0)Rounds4.2downtozerodecimalplacesto4.
=ROUNDDOWN(89.9,0)Rounds89.9downtozerodecimalplacesto89.
=ROUNDDOWN(9.23687,3)Rounds9.23687downtothreedecimalplacesto9.236.
=ROUNDDOWN(-9.23687,1)Rounds-9.23687downtoonedecimalplaceto-9.2.
=ROUNDDOWN(98546.356994,-2)Rounds98546.356994downto2decimalplacestotheleftofthedecimalpointto98500.
8.27.ROUNDUPThisfunctionroundsanumberuptoagivennumberofdigits,awayfromzero.
Syntax:
=ROUNDUP(number,num_digits)
Parameterlist:
number-thenumbertoroundup.
num_digits-thenumberofdigitstowhichnumbershouldberoundedup.
Usagenotes:
TheROUNDUPfunctionworksliketheROUNDfunctionexceptthatwhenrounding,theROUNDUPfunctionwillalwaysroundthenumbers1-9up.
ROUNDUPcanroundeithertotheleftorrightofthedecimalpoint.
Ifnum_digits>0,numberisroundeduptothespecifiednumberofdecimalplacestotherightofthedecimalpoint.
Ifnum_digits<0,numberisroundeduptotheleftofthedecimalpoint(i.e.tothenearest10,100,1000,etc.).
Ifnum_digits=0,numberisroundeduptothenearestinteger.
Examples:
=ROUNDUP(4.2,0)Rounds4.2uptozerodecimalplacesto5.
=ROUNDUP(66.9,0)Rounds66.9uptozerodecimalplacesto67.
=ROUNDUP(8.56987,3)Rounds8.56987uptothreedecimalplacesto8.57.
=ROUNDUP(-9.47952,1)Rounds-9.47952uptoonedecimalplaceto-9.5.
=ROUNDUP(84555.92654,-2)Rounds84555.92654upto2decimalplacestotheleftofthedecimalpointto84600.
8.28.SQRTThisfunctionwillreturnthepositivesquarerootofanumber.
Syntax:
=SQRT(number)
Parameterlist:
number-thenumbertogetthesquarerootof.
Pointstonote.
TheSQRTfunctionwillreturna#NUMerrorwhenaskedtotakethesquarerootofanegativenumber.
8.29.SUBTOTALThisfunctionwillcreateasubtotalinalistordatabase.
Syntax:
SUBTOTAL(function_num,ref1,[ref2],…)
Parameterlist:
function_num-anumberthatspecifieswhichfunctiontouseincalculatingsubtotalswithinalist.Detailsareprovidedbelow.
ref1-anamedrangeorcellreferencetosubtotal.
ref2-[optional]anamedrangeorcellreferencetosubtotal.
Function_numdetails.
Function_numFunction_numFunction
(includeshidden(ignoreshiddenname
values)values)
1101AVERAGE
2102COUNT
3103COUNTA
4104MAX
5105MIN
6106PRODUCT
7107STDEV
8108STDEVP
9109SUM
10110VAR
11111VARP
Pointstonote.
Function_numconstantsfrom1to11,theSUBTOTALfunctionincludesthevaluesofrowshidden.Forthefunction_numconstantsfrom101to111,theSUBTOTALfunctionignoresvaluesofrowshidden.
TheSUBTOTALfunctionignoresanyrowsthatarenotincludedintheresultofafilter,nomatterwhichfunction_numvalueyouuse.SoifyouhavefilteredanyvaluesandwanttofindtheSUMorAVERAGEofthefilteredvaluesyoushouldusethisfunctionasitdoesnotconsidertheunfilteredvalues.Forexample,cellA1hasthevalue10,A2has20andA3has30andifyoufilteroutthevalue10andusetheSUMformulayouwillgetthetotalas60butifyouusetheformulaSUBTOTALtofindoutthetotalthenyouwillgetonlyfilteredvaluestotalwhichis50.
TheSUBTOTALfunctionisdesignedforcolumnsofdata,orverticalranges.
Checktheexamplefileexceltovba.com-SUBTOTAL.xlsx
InthisexamplefirstwearecalculatingthesumofthesubtotalofthecellsA2:A5,using9asthefirstargument.9isforfindingthesumincludinganyhiddenrows.
SecondwearecalculatingtheaverageofthesubtotalofthecellsA2:A5,using1asthefirstargument.1isusedforfindingtheaverageincludinganyhiddenrows.
8.30.SUMSumformulaisoneoftheeasiestandthemostusedformulainExcel.ItisusedtofindtheSumofacellrangesorranges.
Syntax:
SUM(number1,[number2],…)
Parameterlist:
number1-firstnumberyouwanttoadd.Thenumbercanbelike5,acellreferencelikeA6,oracellrangelikeA2:A8.
number2–[Optional]-thesecondnumberyouwanttoadd.Youcanspecifyupto255additionalnumbersinthisway.
Youcanusetheformulaasshownbelow.
1. =SUM(25,65,78)2. =SUM(A1,A2,A3)assuming25,65,78inthecellsA1,A2,A3.3. =SUM(A1:A3)assuming25,65,78inthecellsA1,A2,A3.
Inallthesecasesyouwillget168astheanswer.Buttheeasiestwaytofindtheansweristhethirdone,SUM(A1:A3).
IfyouwanttofindthesumofthecellsfromA1toA20000,youcanjusttype=SUM(A1:A20000)inanyofthecells.
Example1:
Checktheexamplefileexceltovba.com-SUM.xlsxsheetnameOne.
InthisexampleyoucanseethetotalmarkscalculatedinthecellB9usingtheformula=SUM(B2,B3,B4,B5,B6,B7)aswellthetotalmarkscalculatedforthefirsttwostudentsusingtheformula=SUM(B2:B3)inthecellB10.
Alsoyoucanseethetotalmarksforsomeofthestudentsin-betweenusingtheformula=SUM(B2:B3,B5:B6)inthecellB11.
YoucanusethekeyboardshortcutALT+=togetthesumofarangeveryfast.
Example2:UsingSumtofindouttherunningtotal.
PleaseselectthesheetnameTwoandinthatyoucanseewearecalculatingtherunningtotalofthecolumnBincolumnC.
EntertheSUMformulalikethis=SUM($B$2:B2)intheC2cell.InthefirstcellreferenceweareputtingonedollarsigneachbeforethecolumnandrownumbertolockthecellsowhenyoucopythecelldownitwillstillfindtheSUMfromthecellB2tothecelltillyoucopytheformula.
s
Example3:FindouttotalsalesforthreemonthsusingVLOOKUPandSUM.
Checktheexamplefileexceltovba.com-SUM.xlsxsheetnameThree.
InthisexamplefileweareclubbingVLOOKUPwithSUMtofindoutthetotalsalesforthreemonths.FirstwewillchecktheProductnamematchesandthenwewillsumallthesalesfiguresfromJantoMar2015.
Wewillfirstentertheformulalikethis=SUM(VLOOKUP(A10,$A$2:$D$6,{2,3,4},0))inB9,insidethesumwehaveputtheVLOOKUPformulaandthethirdparameterwehavegiventhevaluesasarrayconstantslikethis{2,3,4}sothattheVLOOKUPwillgetthevaluesfromthethreecolumns2,3and4whichisJan,FebandMarchagainsttheproductyouspecifyandmakeanarrayinthememoryandSUMwilltotalthevalues.
SincethisisanarrayformulainsteadofpressingEnterweshouldpressCtrl+Shift+Entersothattheformulawillbechangedto{=SUM(VLOOKUP(A10,$A$2:$D$6,{2,3,4},0))}withcurlybracketsatbeginningandend.ItisimportantyoushouldpressCtrl+Shift+Enterotherwiseitwillgetonlysumoffirstvalueonlyanddon’tentertheCurlybracketsmanuallyExcelwillputthebracketswhenyoupressCtrl+Shift+Enter.
SinceVLOOKUPhastocompareaccordingtothearrayvalue(heretherearethreevaluesineachcomparison{2,3,4})yousupplieditisadvisablenottouseitinbigtablesasitwillslowdowntheExcelconsiderably.InsteadofVLOOKUPyoucanuseINDEXandMATCHfunctions.
Example4:Sumusingnamesinsteadofcellreferences.
PleaseopenthesheetnameFourandherewearefindingouttheTotalsalesbyaddingthesalesforJan,FebandMar.FirstwearenamingtheentirecolumnAtoJanandforthatwewillselecttheentireColumnandthenchangethecellreferenceshownintheNameboxfromA1toJan.LikethatwewillnamethesameforBcolumnandCcolumntoFebandMar.
OnceyouhavedonethatyoucancallthecellreferencefromAcolumnbyJanandBcolumntoFebandCcolumntoMar.
Enter=Jan+Feb+MarintheE2columnandyouwillgettheSumofallmonths.The
beautyofnamingthecellorcellsisyoucancalltheJansalesfigurefromtheZcolumnorAMcolumn,youdon’thavetoremembertheFebsalescolumnisinBorC.
AndsecondthingisyouwillgetthenameofcellsintheAutocompletelistofnamedcellswhenyoutypetheformulaandyoucanpresstheTABbuttontocompletethecellreference.
ThedownsideisifyoudeletethenamedrangesthenyouwillgeterrorbecausetheSUMfunctionwillbelookingforthenamesinsteadofthecellreference.
Example5:UsingOFFSETandSUMtocalculatetheSUMofranges.
GotosheetnameFive,hereweareclubbingtogetherSUMandOFFSETtofindthesales.
FirstwearefindingoutthetotalsaleforJan,forthatwehaveenteredtheformula=SUM(A2:OFFSET(A2,7,0)).OffsetformulawillgivethecellreferenceA8tosecondparameterofSUMfunctionandwillreturntheSumfromA2toA8.LikewisewearecalculatingtheSumofFeb.
AndlastlywearecalculatingtheTotalsalesusingtheformula=SUM(OFFSET(A2,0,D14):OFFSET(A2,7,D15))forthemonthsaccordingtothemonthnumberyouareenteringtothecellreferencesD14andD15,0forJan,1forFeblikethattill6forJuly.Startmonthno.andEndmonthno.arecolumnnumberofOFFSETfunctionfromcellA2.
Example6:
GotosheetnameSix,therewehaveincludesalespersonalsoapartfromtheStartmonthandEndmonth.
8.31.SUMIFThisfunctionisusedtosumnumbersinarangethatmeetthecriteriayousupplied.Forexampleifyouwanttosumonlythevaluesinacellrangewhichisgreaterthan20,youcansettheformulalikethis=SUMIF(A2:A55,”>20”)
Syntax:
=SUMIF(range,criteria,[sum_range])
Parameterlist:
range-therangeofcellsthatyouwanttoapplythecriteriaagainst,mustbenumbersornames,arrays,orreferencesthatcontainnumbers.Blankandtextvaluesareignored.
criteria-thecriteriausedtodeterminewhichcellstoadd.
sum_range-[optional]thecellstoaddtogether.Ifsum_rangeisomitted,thecellsinrangeareaddedtogetherinstead.
Checktheexamplefileexceltovba.com-SUMIF.xlsx
IntheexamplefilefirstwearefindingoutthetotalsaleinthezoneSouth.Forthatfirstwewillselectallthecellrangewhichcontainsthezonename(CellrangeA2:A16)andsecondparameterweareenteringthezonenameitselfwhichisSouth.Youcanenterthenamedirectlyindoublequoteslikethis“South”oryoucanpointtoacellcontainingthetextSouth.
ThirdparameterwearesupplyingthecellrangefromwhichwewanttogettheSumofthesalesofSouthzone(CellrangeB2:B16).
Alsoyoucanusetheformuladirectlytothecellrangelikethis=SUMIF(B2:B16,”>80”)togetthesumofthevalueswhichisgreaterthan80.
Pointstonote.
Anytextorlogicalormathematicalsymbolsmustbeenclosedindoublequotationmarks(“).
Ifthecriteriaisnumericdoublequotationmarksarenotrequired.
Thewildcardcharacters?and*canbeusedincriteria.Aquestionmarkmatchesanyonecharacterandanasteriskmatchesanysequenceofcharacters.Ifyouwanttofindanactualquestionmarkorasterisk,typeatilde(~)precedingthecharacterlikethis~?,~*.
8.32.SUMIFSThisfunctionwilladdthecellsthatmatchmultiplecriteria.
Syntax:
=SUMIFS(sum_range,range1,criteria1,[range2],[criteria2],…)
Parameterlist:
sum_range-Therangetobeadded.
range1-Thefirstrangetoevaulate.
criteria1-Thecriteriatouseonrange1.
range2-[optional]thesecondrangetoevaluate.
criteria2-[optional]thecriteriatouseonrange2.
UnlikeSUMIFfunctionSUMIFSfunctioncancheckmorethanonesetofcriteria.Firstparameteristheonewhichwillbesummed.Thecriteriaistobegivenaspairsandonlythefirstpairiscompulsoryandrestofthepairsareoptional.Youcanenterupto127range/criteriapairs.
Pointstonote.
Usingwildcardcharacterslikethequestionmark(?)andasterisk(*)incriteria1andcriteria2canhelpyoufindmatchesthataresimilarbutnotexact.
Aquestionmarkmatchesanysinglecharacter.Anasteriskmatchesanysequenceofcharacters.Ifyouwanttofindanactualquestionmarkorasterisk,typeatilde(~)infrontofthequestionmark.
Eachadditionalrangemusthavethesamenumberofrowsandcolumnsasthesum_range.
Non-numericcriterianeedstobeenclosedindoublequotesbutnumericcriteriadoesnot.Forexample:100,“100”,“>32”,“jim”,orA1(whereA1containsanumber).
Checktheexamplefileexceltovba.com-SUMIFS.xlsx
InthisexamplefirstwearecheckingthetotalsalesdoneforEastzoneforthemonthofJan.Forthatweareusingtheformula=SUMIFS(D2:D14,A2:A14,A2,C2:C14,C2).FirstparameterwearegivingthecellrangefromwhichweshouldgettheSumandsecondparameterweareprovidingthecellrangefromwhichshouldpickthezoneEast,thirdparameterwehavetogivethecriteriawhichhastobesearchedinthesecondparameter“East”,sincethiscanbehardcodedorwecangiveasacellreferenceandherewehaveprovidedascellreference.
AgainwearegivingthesecondrangeandthecriteriaasfourthandfifthparameterstopicktheJansalesfrommonths.
LikewisewehavedoneforWest,NorthandSouth.
8.33.SUMPRODUCTThisfunctionwillmultiplythecorrespondentcomponentsinthegivenarraysandreturnthesumoftheproduct.Forexample=SUMPRODUCT(A1:A10,B1:B10)willmultiplylikethisA1xB1,A2XB2,A3XB3andaftermultiplyingwillSumthemultipliedvalues.
Syntax:
=SUMPRODUCT(array1,[array2],…)
Parameterlist:
array1-thefirstarrayorrangetomultiply,thenadd.
array2-[optional]Thesecondarrayorrangetomultiply,thenadd.
Thisfunctionismoreversatilethanwhatwesee.SincethisfunctionisusingarrayswecanuseliketheSUMIFSfunction.
Checktheexamplefileexceltovba.com-SUMPRODUCT.xlsxsheet1
InthisexamplefilefirstwearefindingthetotalsalesdonebyVijay.Sowhenthisformulaisexecutedinternallythearraywilllooklikethis.
Array1Array2
FALSE2500
TRUE6500
FALSE5500
FALSE5000
TRUE3500
FALSE4000
Since2ndand5throwhasthenameVijaywewillgetthelogicalvalueTRUEforthosetwocases.SincewecannotmultiplythelogicalvaluewiththeamountasExcelconsidersthelogicalvalueas0wecanchangethelogicalvalueto1and0forTRUEandFALSEusingtwonegativesignsafterthefirstbracket.
Sothetwoarrayswilllooklikethiswhentwonegativesignsareentered.
Array1Array2Product
0*25000
1*65006500
0*55000
0*50000
1*35003500
0*40000
Asyoucanseethisfunctionwillthenmakethetotaloftheproductslikethis6500+3500=10000.Theformulawilllooklikethisafterenteringthedoublenegativevalues,
=SUMPRODUCT({0,1,0,0,1,0},{2500,6500,5500,5000,3500,4000})
8.34.TRUNCThisfunctionremovesthefractionalpartfromthenumbertoaninteger.
Syntax::
TRUNC(number,[num_digits])
Parameterlist:
number-thenumbertotruncate.
num_digits–anumberspecifyingtheprecisionofthetruncation.Thedefaultvaluefornum_digitsis0(zero).
checktheexamplefileexceltovba.com-TRUNC.xls
TRUNCandINTaresimilarfunctions.TRUNCremovesthefractionalpartofthenumber.INTroundsnumbersdowntothenearestintegerbasedonthevalueofthefractionalpartofthenumber.INTandTRUNCaredifferentonlywhenusingnegativenumbers;TRUNC(-8.3)returns-8butINT(-8.3)returns-9because-9isthelowernumber.
9.Statistical9.1.AVERAGEThisformulascalculatestheaverageofagivencellorcellrange.
Syntax:
AVERAGE(number1,[number2],…)
Parameterlist:
number1-thefirstnumber,cellreference,orrangeforwhichyouwanttheaverage.
number2[optional].Additionalnumbers,cellreferencesorrangesforwhichyouwanttheaverage,uptoamaximumof255.
Examples:
=AVERAGE(25,65,78)
=AVERAGE(A1,A2,A3)
=AVERAGE(A1:A3)
Inallthesecasesyouwillget56astheanswer.Buttheeasiestwaytofindtheansweristhethirdone,AVERAGE(A1:A3).IfyouwanttofindtheAVERAGEofthecellsfromA1toA20000,youcanjusttype=AVERAGE(A1:A20000)inanyofthecells.
IntheAVERAGEExcelsheetgotothesheetnameoneandseewhatthethreewaysinwhichsumformulaisused.
InthesheetnametwoyoucanseetheaveragemarkscalculatedinthecellB9usingtheformula=AVERAGE(B2,B3,B4,B5,B6,B7)aswelltheaveragemarkscalculatedforthefirsttwostudentsusingtheformula=AVERAGE(B2:B3)inthecellB10.
Alsoyoucanseetheaveragemarksforsomeofthestudentsin-betweenusingtheformula=AVERAGE(B2:B3,B5:B6)inthecellB11.
9.2.AVERAGEIF
Thisfunctionreturnstheaverageofallthecellinarangethatmeetsthecondition.
Syntax:
AVERAGEIF(range,criteria,[average_range])
Parameterlist:
range-oneormorecellstoaverage,includingnumbersornames,arrays,orreferencesthatcontainnumbers.
criteria-thecriteriaintheformofanumber,expression,cellreference,ortextthatdefineswhichcellsareaveraged.
average_range-[Optional].theactualsetofcellstoaverage.Ifomitted,rangeisused.
Checktheexamplefileexceltovba.com-AVERAGEIF.xlsx
InthisexamplefirsttwoentrieswearecalculatingtheaveragesalesofSouthandNorth.Thirdwearecalculatingtheaveragesalesifthesalesisgreaterthan80.FourthweareagaincalculatingtheaverageofSouthzonebuthereyoucanseetherangeandaverage_rangearedifferentbutstilltheaveragewillbecalculatedontherangeitself.FifthonealsowearecalculatingtheaverageofSouth,eventhoughwehaveselectedtheaverage_rangefullyaveragewillbecalculatedontherangewehaveselectedinthefirstparameter.
AndthelastonewearecalculatingtheaverageofallthezoneswhichisnotSouth.
Pointstonote.
CellsinrangethatcontainTRUEorFALSEareignored.
Ifacellinaverage_rangeisanemptycell,AVERAGEIFignoresit.
Ifrangeisablankortextvalue,AVERAGEIFreturnsthe#DIV0!errorvalue.
Ifacellincriteriaisempty,AVERAGEIFtreatsitasa0value.
Ifnocellsintherangemeetthecriteria,AVERAGEIFreturnsthe#DIV/0!errorvalue.
Youcanusethewildcardcharacters,questionmark(?)(matchesanysinglecharacter)andasterisk(*)(matchesanysequenceofcharacters).Ifyouwanttofindanactualquestionmarkorasterisk,typeatilde(~)beforethecharacter.
Average_rangedoesnothavetobethesamesizeandshapeasrange.Theactualcellsthatareaveragedaredeterminedbyusingthetop,leftcellinaverage_rangeasthebeginningcell,andthenincludingcellsthatcorrespondinsizeandshapetorange
9.3.AVERAGEIFSThisfunctionwillreturntheaverageofallcellsthatmeetmultiplecriteria.
Syntax:
AVERAGEIFS(average_range,criteria_range1,criteria1,[criteria_range2,criteria2],…)
Parameterlist:
average_range–cellorcellstoaverage,includingnumbersornames,arrays,orreferencesthatcontainnumbers.
criteria_range1,criteria_range2,-criteria_range1ismandatoryandsubsequentcriteria_rangesareoptional.Youcansupplyupto127rangeswithcriteria.
criteria1,criteria2,..-criteria1ismandatoryandsubsequentcriteriaareoptional.Youcangiveupto127criteria.Youcansupplythecriterialike85,“89”,“>78”,“Banana”,orA5.
Checktheexamplefileexceltovba.com-AVERAGEIFS.xlsx
InthisexamplefirstwearecalculatingtheaveragepriceofhotelroomfromAcolumnifthetownisinParis,havingmorethan3BedroomsandwithaPersonalChef.
FirstparameterweshouldsupplythecolumnfromwhichwewanttheaveragewhichisA2:A6.
Secondandthirdparameteristhecriteriarange1andcriteria1meanstheentirerangehavingthetownnameandthetownnametosortwhichisB2:B6andParis.
Fourthandthefifthparameteristhesecondcriteriarange(C2:C6)andthecriteria(>2),whichisthenumberofbedroomsandthebedroomsmorethan2.
Sixthandthesevenparameteristhethirdcriteriarange(D2:D6)andthecriteria(Yes),whichmeanswearecheckingwhetherPersonalChefisthereornot.
Secondwe are finding the average of theA columnwhen the town is London and thebedroomisequaltoorlessthan3andwithoutapersonalchef.
ThisfunctionissamelikeusingthefilterfunctioninExcel.
Pointstonote.
Ifaverage_rangeisablankortextornocellsthatmeetallthecriteriaorcellsinaverage_rangecannotbetranslatedintonumbersyouwillget#DIV0!Error.
Ifacellinacriteriarangeisempty,AVERAGEIFStreatsitasa0value.
CellsinrangecontainTRUEwillbetreatedas1andforFALSEwillbetreatedas0.
UnlikeAVERAGEIFfunction,inAVERAGEIFSeachcriteria_rangemustbethesamesizeandshapeassum_range.
Youcanusethewildcardcharacters,questionmark(?)andasterisk(*),incriteria.Aquestionmarkmatchesanysinglecharacter;anasteriskmatchesanysequenceofcharacters.Ifyouwanttofindanactualquestionmarkorasterisk,typeatilde(~)beforethecharacter.
9.3.COUNTThisfunctionwillcountthenumbersgiveninacellreferenceorrange.Forexample,=COUNT(1,8“Orange”)returns2.AndCOUNT(A1:A100)willcountthenumberofnumericvaluesintherangeA1:A100.UseCOUNTtocountnumericvaluesonly.
Syntax:
=COUNT(value1,[value2],…)
Parameterlist:
value1-Anitem,cellreference,orrange.
value2-[optional]Upto255additionalitems,cellreference,orrange.
Pointstonote.
Numbers,dates,oratextrepresentationofnumbers,anumberenclosedinquotationmarks,suchas“1”arecounted.
Logicalvaluesandtextrepresentationsofnumbersthatyoutypedirectlyintothelistofargumentsarecounted.
Errorvaluesortextthatcannotbetranslatedintonumbersarenotcounted.
Ifanargumentisanarrayorreference,onlynumbersinthatarrayorreferencearecounted.
Ifyouwanttocountlogicalvalues,text,orerrorvalues,usetheCOUNTAfunction.
Checktheexamplefileexceltovba.com-COUNT.xlsx
InthisexamplefirstwearecountingthenumberofcellsthatcontainnumbersincellsA2throughA7,logicalvalueanderrorsareavoidedsowewillgetthecountas3.
SecondwearecountingthenumberofcellsthatcontainnumbersincellsA5throughA7.Thesecellshavelogicalvalueanderrorvaluesocountreturns0.
ThirdwearecountingthenumberofcellsthatcontainnumbersincellsA2throughA7,andthevalue2.A2toA7containsonlythreevaluesandthevalue2iscountedasthefourthoneandwewillgettheansweras4.
9.4.COUNTAThisfunctioncountsthenumberofnon-blankcells.COUNTAfunctioncountscellsthatcontainnumbers,text,logicalvalues,errorvalues,andemptytext(””)exceptnon-blankcells.
Syntax:
=COUNTA(value1,[value2],…)
Parameterlist:
value1-anitem,cellreference,orrange.
value2-[optional]anitem,cellreference,orrange.Uptoamaximumof255arguments.
Checktheexamplefileexceltovba.com-COUNTA.xlsx
InthisexampleyoucanseetheCOUNTAfunctioncountsallthevaluesexceptblank
cells.
9.5.COUNTBLANKThisfunctionwillcountcellsthatareblank.Forexample,COUNTBLANK(A1:A100)willcountthenumberofblankcellsintherangeA1:A100.
Syntax:
=COUNTBLANK(range)
Parameterlist:
range-therangeinwhichtocountblankcells.
Pointstonote.
Cellswithformulasthatreturn””(emptytext)arealsocounted.
Cellswithzerovaluesarenotcounted.
9.6.COUNTIFThisfunctioncountcellsthatmatchcriteriaandreturnsanumberrepresentingcellscounted.
Syntax:
=COUNTIF(range,criteria)
Parameterlist:
range-therangeofcellstocount.
criteria-thecriteriathatcontrolswhichcellsshouldbecounted.
Checktheexamplefileexceltovba.com-COUNTIF.xlsx
IntheexamplewearecheckingthecountofthezonenameSouth.ForthatwehavesuppliedthefirstparameterascellrangeA2:A16andsecondparameterSouthitself.Likewisewearecountingeachzones.
Andlastwearecountinghowmanysaleshascrossedabove80.
Moreexamples:
=COUNTIF(A1:A100,200)//countcellsequalto200
=COUNTIF(A1:A100,”>56”)//countcellsgreaterthan56
=COUNTIF(A1:A100,“sam”)//countcellsequalto“sam”
=COUNTIF(A1:A100,”<”&C1)//countcellslessthanvalueinC1
Pointstonote.
Rangecancontainnumbers,arrays,anamedrange,orreferencesthatcontainnumbers.Blankandtextvaluesareignored.
Anytextmustbeenclosedindoublequotationmarks(“).
Ifthecriteriaisnumericdoublequotationmarksarenotrequired.
Thewildcardcharacters?and*canbeusedincriteria.Aquestionmarkmatchesanyonecharacterandanasteriskmatchesanysequenceofcharacters.Ifyouwanttofindanactualquestionmarkorasterisk,typeatilde(~)precedingthecharacterlikethis~?,~*.
9.7.COUNTIFSSyntax:
COUNTIFS(criteria_range1,criteria1,[criteria_range2,criteria2]…)
Parameterlist:
criteria_range1-thefirstrangetoevaluate.
criteria1–thecriteriaforthecriteria_rangelike45,“>65”,B4,“John”,“<5/3/2011”,or“96”.
criteria_range2,criteria2,…[Optional]additionalrangesandtheirassociatedcriteria,upto127range/criteriapairsaresupported.
Example1:
Checktheexamplefileexceltovba.com-COUNTIFS.xlsxSheet1
InthisexamplefirstwearecountingalltheStudentswhohavepassed(indicatedbythetextPass)inJan,FebandMar.Secondwearecountinghowmanyhavefailed.
Thelastonewearecountinghowmanystudentshavepassedinallthethreemonths,forthatfirstwearegivingthefirstcriteriarange(B2:B5)followedbythecriteria‘Pass’followedbysecondcriteriarange(C2:C5)andcriteria‘Pass’andthelastcriteriarange(D2:D5)andcriteria‘Pass’.Sinceonlyonestudenthavepassedtheexaminationinallthethreemonthswewillgettheansweras1.
Example2:
Checktheexamplefileexceltovba.com-COUNTIFS.xlsxSheet2
Inthisexamplefirstwearecountinghowmanynumbersaretherebetween11and16inthecellsA2toA7.
Secondwearecountinghowmanyrowshavenumbersthatarelessthan15incellsA2toA7andhavedatesthatareearlierthan5/04/2015incellsB2toB7.
ThirdweareusingthecellreferenceinsteadoftheconstantsinthecriteriatofindouthowmanyrowshavenumbersthatarelessthanthecellA6whichis15andhavedateslessthanthecellB4whichis‘04/04/2015’,theanswerwillbe2.
Pointstonote.
Eachadditionalrangemusthavethesamenumberofrowsandcolumnsasthecriteria_range1.
Youcanusethewildcardcharacters,questionmark(?)(matchesanysinglecharacter)andasterisk(*)(matchesanysequenceofcharacters)inthecriteria.Ifyouwanttofindanactualquestionmarkorasterisk,typeatilde(~)beforethecharacter.
9.8.FREQUENCYThisfunctionwillcounthowoftenvaluesoccurwithinarangeofvalues,andthenreturnsaverticalarrayofnumbers.
Syntax:
=FREQUENCY(data_array,bins_array)
Parameterlist:
data_array-Anarrayofvaluesforwhichyouwanttogetfrequencies.
bins_array-Anarrayofintervals(“bins”)forgroupingvalues.
Usagenotes:
YoucanuseExcel’sFREQUENCYfunctiontocreateafrequencydistribution-asummarytablethatshowsthefrequency(count)ofeachvalueinarange.FREQUENCYcountshowoftenvaluesoccurinasetofdata.Itreturnsaverticalarrayofnumbersthatrepresentfrequencies.
Checktheexamplefileexceltovba.com-FREQUENCY.xlsx
InthisexamplewearecheckingthecountofscoresaspertheBinsvalues.Firstyouhavetoselectfourcellsandentertheformula=FREQUENCY(A2:A10,B2:B4)andthenpressCTRL+Shift+Entertochangeittoarrayformula.Youcanseeallthecellshasthesamecelladdressandcurlybrackettoindicateitisanarrayformula.
YoucanseetheresultsinthefourcellsfromA13:A16.Firstthisfunctionischeckinghowmanyscoresareatparorbelowthefirstbinvalue55,thenitcheckshowmanyscoresinbetween56to62(abovefirstbinvalueanduptosecondbinvalue).Thirditcheckshowmanyscoresareoccurringbetween63to75(abovesecondbinvalueanduptothirdbinvalue)andlastlyitcheckshowmanyscoresarethereabove75.
Pointstonote.
FREQUENCYalwaysreturnsanarraysoitshouldbeenteredasanarrayformulabypressingCTRL+Shift+Enterafterselectingallthecells.
Thenumberofelementsinthereturnedarrayisonemorethanthenumberofelementsinbins_array.SoiftherearethreeBinsvaluethenyoumustfirstselectfourcellsandthenentertheformula.
9.9.LARGEThisfunctionreturnsthekthlargestvalueinadataset.Forexampleifyouspecifythekvalueas1itwillreturnthelargestvaluefromthegroupandifyouspecify2itwillreturnthesecondlargestvaluefromthegroup.
Syntax:
=LARGE(array,k)
Parameterlist:
array-thedatasetfromwhichyouwanttoselectthekthlargestvalue.
k-integerthatspecifiesthepositionfromthelargestvalue,i.e.thekthposition.
Checktheexamplefileexceltovba.com-LARGE.xlsx
IntheexamplefilewearecalculatingthelargestvaluefromthegroupA2toA6usingtheformula=LARGE(A2:A6,1)andthelargestvalueinthegroupis900andifyouwantthesecondhighestyouhavetoputthesecondparameteras2andyouwillget500andsoon.
Youcanusethisfunctiontofindoutthefirst,secondandthirdpositioninaRaceorExam.
9.10.MAXThisfunctionwillreturnthelargestvaluefromacellrangeignoringlogicalvaluesandtext.
Syntax:
=MAX(number1,[number2],…)
Parameterlist:
number1–thenumberornumbersincellrange
number2–[optional}.1to255numbersforwhichyouwanttofindthemaximumvalue.
Checktheexamplefileexceltovba.com-MAX.xlsx
InthisexamplefileyoucanseewearefindingthehighestvalueinBcolumnandthehighestdateintheCcolumn.
IntheSheet2wearefindingthehighestsalesvalueforeachmonthandalsofindingthesalespersonhighest.
9.11.MEDIANThisfunctionwillreturnthemedianofthenumbers.Themedianisthenumberinthemiddleofasetofnumbers,halfthenumbershavevaluesthataregreaterthanthemedian,andhalfthenumbershavevaluesthatarelessthanthemedian.Forexample,themedianof2,3,3,5,7,and10is4.
Syntax:
=MEDIAN(number1,[number2],…)
Parameterlist:
number1ismandatoryandsubsequentnumbersareoptional.1to255numbersforwhichyouwantthemedian.
Pointstonote.
Whenthetotalnumberofsuppliednumbersiseven,themedianiscalculatedastheaverageofthetwonumbersinthemiddle.
9.12.MINThisfunctionwillreturnthesmallestvaluefromsetofcells.
Syntax:
=MIN(number1,[number2],…)
number1ismandatory,subsequentnumbersareoptional.1to255numbersforwhichyouwanttofindtheminimumvalue.
Checktheexamplefileexceltovba.com-MIN.xlsx
Inthisexamplewearegettingthesmallestvaluefromthegroupwhichistwo.
9.13.MINAThisfunctionreturnstheminimumvalueinalistofarguments,includinglogicalvaluesandtext.
Syntax:
MINA(value1,[value2],…)
Parameterlist:
Value1,value2,…value1isrequired,subsequentvaluesareoptional.1to255valuesforwhichyouwanttofindthesmallestvalue.
Pointstonote.
Argumentscanbenumbers;names,arrays,orreferencesthatcontainnumbers;textrepresentationsofnumbers;orlogicalvalues,suchasTRUEandFALSE,inareference.
Ifanargumentisanarrayorreference,onlyvaluesinthatarrayorreferenceareused.Emptycellsandtextvaluesinthearrayorreferenceareignored.
LogicalvaluesTRUEevaluateas1andFALSEevaluateas0(zero).
Argumentsthatareerrorvaluesortextthatcannotbetranslatedintonumberscauseerrors.
Ifyoudonotwanttoincludelogicalvaluesandtextrepresentationsofnumbersinareferenceaspartofthecalculation,usetheMINfunction.
ThisisthesamelikeMINfunctionexceptituseslogicalvaluesandtextrepresentationsofnumbersinareferenceaspartofthecalculation
9.14.SMALLThisfunctionreturnsthekthsmallestvalueinadataset.Forexampleifyouspecifythe
kvalueas1itwillreturnthelowestvaluefromthegroupandifyouspecify2itwillreturnthesecondlowestvaluefromthegroup.
Syntax:
=SMALL(array,k)
Parameterlist:
array-arangeofcellsfromwhichtoextractsmallestvalues.
k-anintegerthatspecifiesthepositionofthesmallestvalue.
Checktheexamplefileexceltovba.com-SMALL.xlsx
IntheexamplefilewearecalculatingthesmallestvaluefromthegroupA2toA6usingtheformula=SMALL(A2:A6,1)andthesmallestvalueinthegroupis100andifyouwantthesecondhighestyouhavetoputthesecondparameteras2andyouwillget300andsoon.
10.Text10.1.CHARThisfunctioncovertsanormalnumbertothecharacteritrepresentsintheANSIcharacterset.
Syntax:
=CHAR(number)
Parameterlist:
number-Anumberbetween1and255.
CHARcanbeusefulwhenyouwanttospecifycharactersinformulasorfunctionsthatareawkwardorimpossibletotypedirectly.Forexample,youcanuseCHAR(10)toaddalinebreakinaformulaonWindows,andCHAR(13)toaddalinebreakontheMac.
10.2.CLEAN
Thisfunctionremovesanynon-printablecharactersfromtext.Sometimesifyouimportdatafromotherdatabasesitmaycontainnon-printablecharacters.
Syntax:
=CLEAN(text)
Parameterlist:
text-thetexttoclean.
Note:TheCLEANfunctionremovesthefirst32(non-printable)charactersinthe7-bitASCIIcode(values0through31)fromtext.AlsoinUnicodecontainsothernonprintingcharacters(values127,129,141,143,144,and157).
ForexampleiftheA2cellhasthisformula=CHAR(9)&“Monthlyreport”&CHAR(10)therewillbeleadingandtrailingnon-printablecharacters.SotoremovethatyoucanusetheCLEANfunctionlikethis,=CLEAN(A2).BeforeenteringtheCLEANfunctionjustcheckthelengthofthecellA2usingLENfunctionitwillbe16whereastheactuallengthshouldbe14,additional2isthenonprintablecharacters.
10.3.CODEThisfunctionreturnstheANSIvalueofasinglecharacterorthefirstcharacterinatext.TheANSIcharactersetusedbyWindowstoidentifyeachkeyboardcharacterbyusingauniquenumber.Thereare255characterinANSIset.ForExampleANSIcodeforletterAis65,ANSIcodeforletterais97,ANSIcodeforletterBis66.
Syntax:
=CODE(text)
Parameterlist:
text-thetextforwhichyouwantanumericcode.
10.4.CONCATENATEThisfunctionjoinsseveraltextitemsintoonetextitem.CONCATENATEfunctioncombinestextfromdifferentcellsintoonecell.Intheexamplefileenter=CONCATENATE(A2,B2)inthecellC2andyoucanseethecombinedtextinC2.
Youmayhavenoticedthatthefirstandlastnamesdon’thaveaspaceinbetween.That’sbecauseCONCATENATEwillcombineexactlywhatyoutellittocombine,andnothingmore.Ifyouwantpunctuation,spaces,oranyotherdetailstoappearinthecell,you’llneedtotellCONCATENATEtoincludeit.
Toaddaspace,wecansimplyaddanotherargument:””(twodoublequotesaroundaspace).Makesurethethreeargumentsareseparatedbycommas:
=CONCATENATE(A2,”“,B2)
Liketheaboveexampleyoucanaddacomaorawordoranyothercharacterinbetweenthenames.
10.5.DOLLARThisfunctionconvertsanumbertotextformatandappliesacurrencysymbol.
Syntax:
=DOLLAR(number,[decimals])
Parameterlist:
number-thenumbertoconvert.
decimals–[optional]-thenumberofdigitstotherightofthedecimalpoint.Defaultis2.Ifdecimalsisnegative,numberwillberoundedtotheleftofthedecimalpoint.
Usagenotes:
TheDOLLARfunctionconvertsanumbertotextusingcurrencynumberformat.Thenumberformatusedis$#,##0.00_);($#,##0.00).
TheTEXTfunctionisamoreflexiblewaytoachievethesameresult,sinceitcanconvertnumberstotextincurrencyformatandothernumberformatsaswell.
Thecurrencysymbolusedisbasedonlanguagesettingsofthecomputer.
Checktheexamplefileexceltovba.com-DOLLAR.xlsx
10.6.FIXEDThisfunctionroundsthenumbertofixednumberofdecimalsandreturnsastext.
Syntax:
FIXED(number,[decimals],[no_commas])
Parameterlist:
number-thenumberyouwanttoround.
Decimals-thenumberofdigitstotherightofthedecimalpoint,thisisoptional,defaultis2.
no_commas-alogicalTRUEorFALSEforincludingcommasinthereturnedtext,thisisoptional.FALSEoromittedwillhavecommasasusual.
Checktheexamplefileexceltovba.com-FIXED.xlsx
10.7.LEFTThisfunctionreturnstheleftmostcharactersfromatextvaluebasedonthenumberofcharactersyouspecify.
Syntax:
=LEFT(text,[num_chars])
Parameterlist:
text-thetextfromwhichtoextractcharacters.
num_chars-[optional]thenumberofcharacterstoextract,startingontheleftsideoftext.Default=1.
LEFTwillextractdigitsfromnumbersaswell.
10.8.LENThisfunctionreturnsthenumberofcharactersinatextstring.
Syntax:
=LEN(text)
Parameterlist:
text-Thetextforwhichtocalculatelength.
Checktheexamplefileexceltovba.com-LEN.xlsx
InthisexamplewearecheckingthelengthofeachtextusingtheLenfunctionandyoucanseethelengthofthelastword‘This’isshownas5whereasthereareonlyfourcharactersintheword‘This’.Thisisbecausethereisasinglespacecharacterafterthecharacter‘s’.IfyouwanttoremovetheexcessspaceyoucanusetheTRIMfunction.
10.9.LOWERThisfunctionconvertstexttolowercase.
Syntax:
=LOWER(Text)
Parameterlist:
text-thetextinaworksheetcelltobechanged.
Thetextargumentcanbe
acellreferencelikethis=LOWER(A1)
awordorwordsenclosedinquotationmarkslikethis=LOWER(“THISISFUN”)
aformulathatoutputstextlikethis=LOWER(CONCATENATE(A4,A5,A6)),willmergeallthedatainthecellA4,A5andA6andchangethecasetolower.
Checktheexamplefileexceltovba.com-LOWER.xls
10.10.MIDThisfunctionreturnsaspecificnumberofcharactersfromatextstring,startingatthepositionyouspecify.
Syntax:
=MID(text,start_num,num_chars)
Parameterlist:
text-thetexttoextractfrom.
start_num-thelocationofthefirstcharactertoextract.
num_chars-thenumberofcharacterstoextract.
Checktheexamplefileexceltovba.com-MID.xls
10.11.PROPERPROPERcapitalizesthefirstletterineachwordofatextvalue.Asyoucanseeinexamplegivenbelowthefirstletterofthewordiscapitalized.
10.12.REPLACEThisfunctionreplacetextbasedonlocationandreturnsthealteredtext.
Syntax:
=REPLACE(old_text,start_num,num_chars,new_text)
Parameterlist:
old_text-Thetexttoreplace.
start_num-Thestartinglocationinthetexttosearch.
num_chars-Thenumberofcharacterstoreplace.
new_text-Thetexttoreplaceold_textwith.
Pointstonote.
UsetheREPLACEfunctionwhenyouwanttoreplacetextbasedonitslocationinastring.
UseFINDorSEARCHtofindthelocationoftexttoreplaceitifit’snotknowninadvance.
UseSUBSTITUTEtoreplacetextbasedoncontent.
10.13.REPTThisfunctionrepeatsatextagivennumberoftimes.
Syntax:
=REPT(text,number_times)
Parameterlist:
text-thetexttorepeat.
number_times-thenumberoftimestorepeattext.
10.14.RIGHTThisfunctionreturnstherightmostcharactersfromatextasperthenumberofcharactersyouspecify.
Syntax:
=RIGHT(text,[num_chars])
Parameterlist:
text-thetextfromwhichtoextractcharactersontheright.
num_chars-[optional]thenumberofcharacterstoextract,startingontheright.Optional,default=1.
Checktheexamplefileexceltovba.com-RIGHT.xls
10.15.SEARCHThisfunctionwillreturnanumberrepresentingthelocationoftextinastring.Forexample=SEARCH(“a”,”Orange”)willreturn3as“a”isinthethirdposition.
Syntax:
=SEARCH(find_text,within_text,start_num)
Parameterlist:
find_text-thetexttofind.
within_text-thetexttosearchwithin.
start_num-startingpositioninthetexttosearch.Optional,defaultsto1.
Checktheexamplefileexceltovba.com-SEARCH.xls
ThisfunctionissamelikeFINDfunctionandthemaindifferenceisSEARCHallowstheuseofwildcardsandisnotcase-sensitive.
SEARCHallowsthewildcardcharactersquestionmark(?)andasterisk(*),infind_text.The?matchesanysinglecharacterandthe*matchesanysequenceofcharacters.Tofindaliteral?or*,useatilde(~)beforethecharacter,i.e.~*and~?.
10.16.SUBSTITUTEThisfunctionwillsubstitutenewtextintothetextstringagainsttheoldtextyouspecify.ItisliketheFindandReplaceintheExcel.
Syntax:
=SUBSTITUTE(text,old_text,new_text,[instance])
Parameterlist:
text-Thetexttochange.
old_text-Thetexttoreplace.
new_text-Thetexttoreplacewith.
instance–Optionalargument;ifnotsupplied,alloccuranceofold_textarereplacedwithnew_text.
Pointstonote.
SUBSTITUTEiscase-sensitiveanddoesnotsupportwildcardslike?or*.
Checktheexamplefileexceltovba.com-SUBSTITUTE.xls
Inthefirstentrywearesubstitutingthenamejohnwithvijay.
Inthesecondentrywearedoingthesamethingbutsincetheforthparameterwehavegivenas1itwillsubstituteonlythefirstoccurrence.
SinceSUBSTITUTEfunctioniscasesensitiveitwillnotsubstitutethesecondoccurrenceofjohnwithvijayinthethirdentry.
10.17.TThisfunctionreturnsthetextreferredtobyvalue.
Syntax:
T(value)
Parameterlist:
Value-thevalueyouwanttotest.
Ifvalueisorreferstotext,Treturnsvalue.Ifvaluedoesnotrefertotext,Treturns””(emptytext).
YoudonotgenerallyneedtousetheTfunctioninaformulabecauseMicrosoftExcelautomaticallyconvertsvaluesasnecessary.Thisfunctionisprovidedforcompatibilitywithotherspreadsheetprograms.
10.18.TEXTThisfunctionconvertsanumbertotextandletsyouspecifythedisplayformattingbyusingformatstrings.Forexample,supposecellA1containsthenumber43.8.Toformatthenumberasadollaramount,youcanusethefollowingformulaTEXT(A1,”$0.00”)andyouwillgettheanswer$43.8.
Youcanalsoaddatexttotheprecedingformulalikethis=TEXT(A1,”$0.00”)&”perMiles”togettheanswerlikethis$43.8perMiles.
Syntax:
=TEXT(value,format_text)
Parameterlist:
value-Thenumbertoconvert.
format_text-Thenumberformattouse,mustappearindoublequotationmarks.For
example“m/d/yyyy”or“#,##0.00”
Completelistofformat_textisthereinthesitehttps://support.office.com.
10.19.TRIMThisfunctionwillremoveextraspacesfromtextfrombeginningandend.TRIMremovesextraspacesfromtext,leavingonlysinglespacesbetweenwordsandnospacecharactersatthestartorendofthetext.
Syntax:
=TRIM(text)
Parameterlist:
text-Thetextfromwhichtoremoveextraspace.
TRIMisusefulwhencleaninguptextthatisbeeninsertedfromotherSoftwares.AlsoTRIMcanbeusedbeforeusingaVLOOKUPfunctiontocleartheextraleadingandtrailingspaces.
10.20.UPPERThisfunctionisusedtochangethecaseoftheletter,inthiscasetouppercase.
Syntax:
=UPPER(Text)
Text-thetextinaworksheetcelltobechanged.Thetextargumentcanbe
acellreferencelikethis=UPPER(A1)
awordorwordsenclosedinquotationmarkslikethis=UPPER(“ThisisFun”)
aformulathatoutputstextlikethis=UPPER(CONCATENATE(A4,A5,A6)),willmergeallthedatainthecellA4,A5andA6andchangethecasetoupper.
Checktheexamplefileexceltovba.com-UPPER.xls
10.21.VALUEThisfunctionisusedtoconverttexttoanumericvalue.TheVALUEfunctionconverts
textthatappearsinarecognizedformat(i.e.anumber,date,ortimeformat)intoanumericvalue.
Syntax:
VALUE(text)
Parameterlist:
text-thetextenclosedinquotationmarksorareferencetoacellcontainingthetextyouwanttoconvert.
Normally,Excelautomaticallyconvertstexttonumericvaluesasneededbutinsomecaseswemaygetdatafromothersoftware’sthatwilllooklikenumbersbutwillbeintextformatandwewillnotbeabletodoanycalculationonthat,inthiscasewehavetoconvertthetexttonumericalvalue.
Iftextisnotinoneoftheseformats,VALUEreturnsthe#VALUE!errorvalue.
10.22.FINDThisfunctiongetthelocationoftextinastringandreturnsanumberrepresentingthelocation.
Syntax:
=FIND(find_text,within_text,[start_num])
Parameterlist:
find_text-Thetexttofind.
within_text-Thetexttosearchwithin.
start_num-[optional]Thestartingpositioninthetexttosearch,defaultsto1.
Checktheexamplefileexceltovba.com-FIND.xls
Firstformulawearefindingwheretheletter“i”starts.
Secondformulawehaveaddedthethirdparameter4soFINDwillsearchfromfourthletteronlyandwillignorethe“i”whichisthethirdletter.
Thirdformulawearefindingtheword“doing”fromthesentenceHowareyoudoing?
FourthformulaagainwearesearchingtheworddoingsinceFINDiscasesensitivewe
willgetthe#VALLUEerror.
Pointstonote.
FINDwillreturn#VALUEiffind_textisnotfoundinwithin_text.
FINDiscase-sensitiveanddoesnotsupportwildcards.
ConclusionHopeyouhavelearnednewthingsfrommybookExcelFormulas.
IftheselessonshavehelpedyouandfounditusefulpleasewriteareviewforthisbookonAmazon,themorereviewsthelessongets,theeasiertheotherswillbeabletofindit.ItakereviewsseriouslyandalwayslookatthempersonallyandifIthinkyourreviewisuseful,Iwillmarkitas“helpful”.
Onceagainthankingyouforreadingthisbook.
ExamplefilecanbedownloadedfromExceltoVBA.com
Passwordisexcelformulas@2016
AbouttheAuthorHi,mynameisVijayKumarandI‘amcrazyaboutlearningaswellasteachingExcel.ThisbookisacompilationoftheknowledgeIhaveacquiredbyteachingaswelllearningExcelfromthepastfewyears.
MyOtherBooks.
ExcelShortcuts:130ShortcutsthatwillchangeyourlifeforeverThisbookcoversvariousshortcutsfromBasictoAdvancelevelinFormatting,Dataediting,Selection,Navigationandotherusefulshortcutswithexamples.
ThesearesomeofthebenefitsoflearningShortcuts.
•Increaseyourproductivitybyspeederexecutionoftasks.
•Willincreasetheaccuracyoftheworkyouaredoing.
•HelptogetRaisesandPromotion.
•ToimpressyourBossandColleagues.
•Itisfuntousetheshortcuts.
Youcandownloadthebookfromthislink.
http://www.amazon.com/Excel-Shortcuts-that-change-forever-ebook/dp/B01497NDNK/ref=sr_1_2?ie=UTF8&qid=1459075093&sr=8-2&keywords=excel+shortcuts