108
Microsoft Excel Functions, Macros & Data Commands J. Carlton Collins, CPA ASA Research Atlanta, Georgia 770.734.0950 [email protected] A SA Research

2010 Excel Functions Macros and Data Commands Manual as of March 2010

Embed Size (px)

Citation preview

  • MicrosoftExcelFunctions,Macros&DataCommands

    J.CarltonCollins,CPAASAResearch

    Atlanta,Georgia770.734.0950

    [email protected]

    A S A R e s e a r c h

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page2 CopyrightMay2010

    TableofContentsChapter1ExcelFunctions..........................................................................4Chapter2TheIfFunction.........................................................................18Chapter3UsingFunctionstoClean&CrunchData.................................23Chapter4DataCommands......................................................................41Chapter5Macros.....................................................................................76Chapter6Miscellaneous.........................................................................81Chapter7XMLData.................................................................................84Chapter8QuickTips................................................................................92Chapter9WhatsNewinExcel2007.......................................................95Chapter10WhatsnewinExcel2010....................................................104AppendixInstructorsBiography............................................................108

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page3 CopyrightMay2010

    ExcelFunctions,Macros&DataCommandsCourseInformation

    LearningObjectives ToincreasetheproductivityofaccountantsandCPAs

    usingExcelsfunctions,macros,&datacommandsCourseLevel IntermediatePreRequisites GoodFamiliaritywithMicrosoftExcelAdvancedPreparation NonePresentationMethod Livelectureusingfullcolorprojectionsystemsand

    liveInternetaccesswithfollowupcoursematerialsRecommendedCPECredit 8hoursHandouts Templates,checklists,webexamples,manualInstructors J.CarltonCollins,CPA

    AdvisorCPE isregisteredwiththeNationalAssociationofState Boards of Accountancy (NASBA) as a sponsor ofcontinuing professional education on the NationalRegistry of CPE Sponsors. State boards of accountancyhave final authority on the acceptance of individualcourses for CPE credit. Complaints regarding registeredsponsors may be addressed to the national Registry ofCPE Sponsors,150 FourthAvenue,Nashville,TN,372192417.Telephone:6158804200.

    CopyrightMay2010,AdvisorCPEandAccountingSoftwareAdvisor,LLC4480MissendellLane,Norcross,Georgia30092770.734.0450

    Allrightsreserved.NopartofthispublicationmaybereproducedortransmittedinanyformwithouttheexpresswrittenconsentofAdvisorCPEorASAResearch,subsidiariesofAccountingSoftwareAdvisor,LLC.Requestmaybeemailed to [email protected] or further information can be obtained by calling 770.734.0450 or byaccessingtheAdvisorCPEhomepageat:http://www.advisorcpe.com/Alltradenamesandtrademarksusedinthesematerialsarethepropertyoftheirrespectivemanufacturersand/orowners.Theuseoftradenamesandtrademarksusedinthesematerialsarenotintendedtoconveyendorsementof any other affiliations with these materials. Any abbreviations used herein are solely for the readersconvenience and arenot intended to compromise any trademarks. Someof the featuresdiscussedwithin thismanualapplyonlytocertainversionsofExcel,andfromtimetotime,Microsoftmightremovesomefunctionality.Microsoft Excel is known to contain numerous software bugswhichmay prevent the successful use of somefeatures insomecases.AdvisorCPEmakesnorepresentationsorwarrantywithrespecttothecontentsofthesematerialsanddisclaimsanyimpliedwarrantiesofmerchantabilityoffitnessforanyparticularuse.Thecontentsofthesematerialsaresubjecttochangewithoutnotice.

    ContactInformation:J.CarltonCollins

    [email protected]

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page4 CopyrightMay2010

    Chapter1

    ExcelFunctions

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page5 CopyrightMay2010

    IntroductiontoExcelFunctionsExcelFunctionsarepreprogrammedformulasthatmakethetaskofwritingcomplexformulaseasier. There are a total of 333 functions in Excel. These functions are separated into 11categoriesasfollows:

    Categories&NumberOfFunctionsInEachCategory

    1. DatabaseFunctions(12)2. DateandTimeFunctions(20)3. EngineeringFunctions(39)4. FinancialFunctions(53)5. InformationFunctions(17)6. LogicalFunctions(6)7. LookupandReferenceFunctions(18)8. MathandTrigonometryFunctions(59)9. StatisticalFunctions(80)10. TextFunctions(27)11. ExternalFunctions(2)

    RelevancetoCPAsSomeExcelfunctionsaremorepowerfulthanothersandsomearemorerelevant to the CPA than others. For example, most CPAs will find the IF, SUM, COUNT,SUBTOTAL, TEXT, and VLOOKUP are very relevant to the CPA while other engineering andtrigonometry functions such as LOG,PI,RADIENS,DELTA, TAN,COMPLEX, andHAX2DEC aretypically lessrelevanttoCPAs. Ithasbeenmyexperiencethatthefollowing75functionsaremostrelevanttotheCPA;thereforeinmyopinion,CPAswishingtoincreasetheircommandofExcelfunctionsshouldconcentrateonthesefunctionsfirst.

    CarltonsListofTheTop75FunctionsMostRelevanttoCPAs(SortedByCarltonsOpinionofUsefulness)

    OpenanExcelfileContainingFunctionExamples:http://www.ASAResearch.com/web/functions.xlsx

    1. IFSpecifiesalogicaltesttoperform2. SUMAddsitsarguments3. SUBTOTALReturnsasubtotalinalistordatabase4. SUMIFAddsthecellsspecifiedbyagivencriteria5. COUNTCountshowmanynumbersareinthelistofarguments6. COUNTACountshowmanyvaluesareinthelistofarguments7. AVERAGEReturnstheaverageofarangeofnumbers8. COUNTBLANKCountsthenumberofblankcellswithinarange9. COUNTIFCountsthenumberofnonblankcellswithinarangethatmeetthegivencriteria10. VALUEConvertstexttoanumber11. TEXTFormatsanumberandconvertsittotext

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page6 CopyrightMay2010

    12. VLOOKUPLooksinthefirstcolumnofanarrayandmovesacrosstherowtoreturnthevalueofacell

    13. HLOOKUPLooksinthetoprowofanarrayandreturnsthevalueoftheindicatedcell14. TWOWAYLOOKUPUsingbothVLOOKUPandHLOOKUPtogether15. LOOKUPLooksupvaluesinavectororarray16. MATCHLooksupvaluesinareferenceorarray17. TRIMRemovesspacesfromtext18. PROPERCapitalizesthefirstletterineachwordofatextvalue19. LOWERConvertstexttolowercase20. UPPERConvertstexttouppercase21. LEFTReturnstheleftmostcharactersfromatextvalue22. RIGHTReturnstherightmostcharactersfromatextvalue23. MID Returnsa specificnumberof characters froma text string startingat thepositionyou

    specify24. FINDFindsonetextvaluewithinanother(casesensitive)25. SUBSTITUTESubstitutesnewtextforoldtextinatextstring26. LENReturnsthenumberofcharactersinatextstring27. REPLACEReplacestextinastringwithalternativetext28. CONCATENATEJoinsseveraltextitemsintoonetextitem29. CLEANRemovesallnonprintablecharactersfromtext30. NOWReturnstheserialnumberofthecurrentdateandtime31. TODAYReturnstheserialnumberoftoday'sdate32. DATEReturnstheserialnumberofaparticulardate33. MONTHConvertsaserialnumbertoamonth34. DAYConvertsaserialnumbertoadayofthemonth35. YEARConvertsaserialnumbertoayear36. WEEKDAYConvertsaserialnumbertoadayoftheweek37. ROUNDRoundsanumbertoaspecifiednumberofdigits38. ROUNDDOWNRoundsanumberdown,towardzero39. ROUNDUPRoundsanumberup,awayfromzero40. MAXReturnsthemaximumvalueinalistofarguments41. DMAXReturnsthemaximumvaluefromatablearraybasedonalistofarguments42. MINReturnstheminimumvalueinalistofarguments43. DMINReturnstheminimumvaluefromatablearraybasedonalistofarguments44. MEDIANReturnsthemedianofthegivennumbers45. MODEReturnsthemostcommonvalueinadataset46. PERCENTILEReturnsthekthpercentileofvaluesinarange47. PERCENTRANKReturnsthepercentagerankofavalueinadataset48. PMTReturnstheperiodicpaymentforanannuity49. NPVReturnsthenetpresentvalueofan investmentbasedonaseriesofperiodiccashflows

    andadiscountrate50. DSUMAddsthenumbersinthefieldcolumnofrecordsinthedatabasethatmatchthecriteria51. DCOUNTCountsthecellsthatcontainnumbersinadatabase52. DCOUNTACountsnonblankcellsinadatabase53. ANDReturnsTRUEifallofitsargumentsareTRUE

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page7 CopyrightMay2010

    54. ORReturnsTRUEifanyargumentisTRUE55. CHOOSEChoosesavaluefromalistofvalues56. TIMEReturnstheserialnumberofaparticulartime57. FVReturnsthefuturevalueofaninvestment58. IRRReturnstheinternalrateofreturnforaseriesofcashflows59. YIELDReturnstheyieldonasecuritythatpaysperiodicinterest60. CELLReturnsinformationabouttheformatting,location,orcontentsofacell61. INFOReturnsinformationaboutthecurrentoperatingenvironment62. ERROR.TYPEReturnsanumbercorrespondingtoanerrortype63. ISBLANKReturnsTRUEifthevalueisblank64. ISNAReturnsTRUEifthevalueisthe#N/Aerrorvalue65. GETPIVOTDATAReturnsdatastoredinaPivotTable66. HYPERLINKCreatesashortcutorjumpthatopensadocumentstoredonanetworkserver,an

    intranet,ortheInternet67. TRANSPOSEReturnsthetransposeofanarray68. ABSReturnstheabsolutevalueofanumber69. RANDReturnsarandomnumberbetween0and170. RANDBETWEENReturnsarandomnumberbetweenthenumbersyouspecify71. REPTRepeatstextagivennumberoftimes72. SLNReturnsthestraightlinedepreciationofanassetforoneperiod73. SYDReturnsthesumofyears'digitsdepreciationofanassetforaspecifiedperiod74. DDBReturnsthedoubledecliningbalancedepreciationofanassetforaspecifiedperiod75. DGETExtractsfromadatabaseasinglerecordthatmatchesthespecifiedcriteria

    'J.CarltonCollins,CPACopyright,January2007,[email protected]

    All333ExcelFunctionsOrganizedByCategory,IncludingADescriptionOfEachFunction

    DatabaseFunctions Function Description1 DAVERAGE Returnstheaverageofselecteddatabaseentries2 DCOUNT Countsthecellsthatcontainnumbersinadatabase3 DCOUNTA Countsnonblankcellsinadatabase4 DGET Extractsfromadatabaseasinglerecordthatmatchesthespecifiedcriteria5 DMAX Returnsthemaximumvaluefromselecteddatabaseentries6 DMIN Returnstheminimumvaluefromselecteddatabaseentries7 DPRODUCT Multipliesthevaluesinaparticularfieldofrecordsthatmatchthecriteriain

    adatabase8 DSTDEV Estimatesthestandarddeviationbasedonasampleofselecteddatabase

    entries9 DSTDEVP Calculatesthestandarddeviationbasedontheentirepopulationofselected

    databaseentries10 DSUM Addsthenumbersinthefieldcolumnofrecordsinthedatabasethatmatch

    thecriteria

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page8 CopyrightMay2010

    11 DVAR Estimatesvariancebasedonasamplefromselecteddatabaseentries12 DVARP Calculatesvariancebasedontheentirepopulationofselecteddatabase

    entries DateandTimeFunctions Function Description13 DATE Returnstheserialnumberofaparticulardate14 DATEVALUE Convertsadateintheformoftexttoaserialnumber15 DAY Convertsaserialnumbertoadayofthemonth16 DAYS360 Calculatesthenumberofdaysbetweentwodatesbasedona360dayyear17 EDATE Returnstheserialnumberofthedatethatistheindicatednumberofmonths

    beforeorafterthestartdate18 EOMONTH Returnstheserialnumberofthelastdayofthemonthbeforeoraftera

    specifiednumberofmonths19 HOUR Convertsaserialnumbertoanhour20 MINUTE Convertsaserialnumbertoaminute21 MONTH Convertsaserialnumbertoamonth22 NETWORKDAYS Returnsthenumberofwholeworkdaysbetweentwodates23 NOW Returnstheserialnumberofthecurrentdateandtime24 SECOND Convertsaserialnumbertoasecond25 TIME Returnstheserialnumberofaparticulartime26 TIMEVALUE Convertsatimeintheformoftexttoaserialnumber27 TODAY Returnstheserialnumberoftoday'sdate28 WEEKDAY Convertsaserialnumbertoadayoftheweek29 WEEKNUM Convertsaserialnumbertoanumberrepresentingwheretheweekfalls

    numericallywithayear30 WORKDAY Returnstheserialnumberofthedatebeforeorafteraspecifiednumberof

    workdays31 YEAR Convertsaserialnumbertoayear32 YEARFRAC Returnstheyearfractionrepresentingthenumberofwholedaysbetween

    start_dateandend_date EngineeringFunctions Function Description33 BESSELI ReturnsthemodifiedBesselFunctionIn(x)34 BESSELJ ReturnstheBesselFunctionJn(x)35 BESSELK ReturnsthemodifiedBesselFunctionKn(x)36 BESSELY ReturnstheBesselFunctionYn(x)37 BIN2DEC Convertsabinarynumbertodecimal38 BIN2HEX Convertsabinarynumbertohexadecimal39 BIN2OCT Convertsabinarynumbertooctal

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page9 CopyrightMay2010

    40 COMPLEX Convertsrealandimaginarycoefficientsintoacomplexnumber41 CONVERT Convertsanumberfromonemeasurementsystemtoanother42 DEC2BIN Convertsadecimalnumbertobinary43 DEC2HEX Convertsadecimalnumbertohexadecimal44 DEC2OCT Convertsadecimalnumbertooctal45 DELTA Testswhethertwovaluesareequal46 ERF ReturnstheerrorFunction47 ERFC ReturnsthecomplementaryerrorFunction48 GESTEP Testswhetheranumberisgreaterthanathresholdvalue49 HEX2BIN Convertsahexadecimalnumbertobinary50 HEX2DEC Convertsahexadecimalnumbertodecimal51 HEX2OCT Convertsahexadecimalnumbertooctal52 IMABS Returnstheabsolutevalue(modulus)ofacomplexnumber53 IMAGINARY Returnstheimaginarycoefficientofacomplexnumber54 IMARGUMENT Returnstheargumenttheta,anangleexpressedinradians55 IMCONJUGATE Returnsthecomplexconjugateofacomplexnumber56 IMCOS Returnsthecosineofacomplexnumber57 IMDIV Returnsthequotientoftwocomplexnumbers58 IMEXP Returnstheexponentialofacomplexnumber59 IMLN Returnsthenaturallogarithmofacomplexnumber60 IMLOG10 Returnsthebase10logarithmofacomplexnumber61 IMLOG2 Returnsthebase2logarithmofacomplexnumber62 IMPOWER Returnsacomplexnumberraisedtoanintegerpower63 IMPRODUCT Returnstheproductoffrom2to29complexnumbers64 IMREAL Returnstherealcoefficientofacomplexnumber65 IMSIN Returnsthesineofacomplexnumber66 IMSQRT Returnsthesquarerootofacomplexnumber67 IMSUB Returnsthedifferencebetweentwocomplexnumbers68 IMSUM Returnsthesumofcomplexnumbers69 OCT2BIN Convertsanoctalnumbertobinary70 OCT2DEC Convertsanoctalnumbertodecimal71 OCT2HEX Convertsanoctalnumbertohexadecimal FinancialFunctions Function Description72 ACCRINT Returnstheaccruedinterestforasecuritythatpaysperiodicinterest73 ACCRINTM Returnstheaccruedinterestforasecuritythatpaysinterestatmaturity74 AMORDEGRC Returnsthedepreciationforeachaccountingperiodbyusingadepreciation

    coefficient75 AMORLINC Returnsthedepreciationforeachaccountingperiod

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page10 CopyrightMay2010

    76 COUPDAYBS Returnsthenumberofdaysfromthebeginningofthecouponperiodtothesettlementdate

    77 COUPDAYS Returnsthenumberofdaysinthecouponperiodthatcontainsthesettlementdate

    78 COUPDAYSNC Returnsthenumberofdaysfromthesettlementdatetothenextcoupondate

    79 COUPNCD Returnsthenextcoupondateafterthesettlementdate80 COUPNUM Returnsthenumberofcouponspayablebetweenthesettlementdateand

    maturitydate81 COUPPCD Returnsthepreviouscoupondatebeforethesettlementdate82 CUMIPMT Returnsthecumulativeinterestpaidbetweentwoperiods83 CUMPRINC Returnsthecumulativeprincipalpaidonaloanbetweentwoperiods84 DB Returnsthedepreciationofanassetforaspecifiedperiodbyusingthefixed

    decliningbalancemethod85 DDB Returnsthedepreciationofanassetforaspecifiedperiodbyusingthe

    doubledecliningbalancemethodorsomeothermethodthatyouspecify86 DISC Returnsthediscountrateforasecurity87 DOLLARDE Convertsadollarprice,expressedasafraction,intoadollarprice,expressed

    asadecimalnumber88 DOLLARFR Convertsadollarprice,expressedasadecimalnumber,intoadollarprice,

    expressedasafraction89 DURATION Returnstheannualdurationofasecuritywithperiodicinterestpayments90 EFFECT Returnstheeffectiveannualinterestrate91 FV Returnsthefuturevalueofaninvestment92 FVSCHEDULE Returnsthefuturevalueofaninitialprincipalafterapplyingaseriesof

    compoundinterestrates93 INTRATE Returnstheinterestrateforafullyinvestedsecurity94 IPMT Returnstheinterestpaymentforaninvestmentforagivenperiod95 IRR Returnstheinternalrateofreturnforaseriesofcashflows96 ISPMT Calculatestheinterestpaidduringaspecificperiodofaninvestment97 MDURATION ReturnstheMacauleymodifieddurationforasecuritywithanassumedpar

    valueof$10098 MIRR Returnstheinternalrateofreturnwherepositiveandnegativecashflowsare

    financedatdifferentrates99 NOMINAL Returnstheannualnominalinterestrate100 NPER Returnsthenumberofperiodsforaninvestment101 NPV Returnsthenetpresentvalueofaninvestmentbasedonaseriesofperiodic

    cashflowsandadiscountrate102 ODDFPRICE Returnsthepriceper$100facevalueofasecuritywithanoddfirstperiod103 ODDFYIELD Returnstheyieldofasecuritywithanoddfirstperiod104 ODDLPRICE Returnsthepriceper$100facevalueofasecuritywithanoddlastperiod105 ODDLYIELD Returnstheyieldofasecuritywithanoddlastperiod106 PMT Returnstheperiodicpaymentforanannuity

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page11 CopyrightMay2010

    107 PPMT Returnsthepaymentontheprincipalforaninvestmentforagivenperiod108 PRICE Returnsthepriceper$100facevalueofasecuritythatpaysperiodicinterest109 PRICEDISC Returnsthepriceper$100facevalueofadiscountedsecurity110 PRICEMAT Returnsthepriceper$100facevalueofasecuritythatpaysinterestat

    maturity111 PV Returnsthepresentvalueofaninvestment112 RATE Returnstheinterestrateperperiodofanannuity113 RECEIVED Returnstheamountreceivedatmaturityforafullyinvestedsecurity114 SLN Returnsthestraightlinedepreciationofanassetforoneperiod115 SYD Returnsthesumofyears'digitsdepreciationofanassetforaspecified

    period116 TBILLEQ ReturnsthebondequivalentyieldforaTreasurybill117 TBILLPRICE Returnsthepriceper$100facevalueforaTreasurybill118 TBILLYIELD ReturnstheyieldforaTreasurybill119 VDB Returnsthedepreciationofanassetforaspecifiedorpartialperiodbyusing

    adecliningbalancemethod120 XIRR Returnstheinternalrateofreturnforascheduleofcashflowsthatisnot

    necessarilyperiodic121 XNPV Returnsthenetpresentvalueforascheduleofcashflowsthatisnot

    necessarilyperiodic122 YIELD Returnstheyieldonasecuritythatpaysperiodicinterest123 YIELDDISC Returnstheannualyieldforadiscountedsecurity;forexample,aTreasurybill124 YIELDMAT Returnstheannualyieldofasecuritythatpaysinterestatmaturity InformationFunctions Function Description125 CELL Returnsinformationabouttheformatting,location,orcontentsofacell126 ERROR.TYPE Returnsanumbercorrespondingtoanerrortype127 INFO Returnsinformationaboutthecurrentoperatingenvironment128 ISBLANK ReturnsTRUEifthevalueisblank129 ISERR ReturnsTRUEifthevalueisanyerrorvalueexcept#N/A130 ISERROR ReturnsTRUEifthevalueisanyerrorvalue131 ISEVEN ReturnsTRUEifthenumberiseven132 ISLOGICAL ReturnsTRUEifthevalueisalogicalvalue133 ISNA ReturnsTRUEifthevalueisthe#N/Aerrorvalue134 ISNONTEXT ReturnsTRUEifthevalueisnottext135 ISNUMBER ReturnsTRUEifthevalueisanumber136 ISODD ReturnsTRUEifthenumberisodd137 ISREF ReturnsTRUEifthevalueisareference138 ISTEXT ReturnsTRUEifthevalueistext139 N Returnsavalueconvertedtoanumber

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page12 CopyrightMay2010

    140 NA Returnstheerrorvalue#N/A141 TYPE Returnsanumberindicatingthedatatypeofavalue17 LogicalFunctions Function Description142 AND ReturnsTRUEifallofitsargumentsareTRUE143 FALSE ReturnsthelogicalvalueFALSE144 IF Specifiesalogicaltesttoperform145 NOT Reversesthelogicofitsargument146 OR ReturnsTRUEifanyargumentisTRUE147 TRUE ReturnsthelogicalvalueTRUE LookupandReferenceFunctions Function Description148 ADDRESS Returnsareferenceastexttoasinglecellinaworksheet149 AREAS Returnsthenumberofareasinareference150 CHOOSE Choosesavaluefromalistofvalues151 COLUMN Returnsthecolumnnumberofareference152 COLUMNS Returnsthenumberofcolumnsinareference153 GETPIVOTDATA ReturnsdatastoredinaPivotTable154 HLOOKUP Looksinthetoprowofanarrayandreturnsthevalueoftheindicatedcell155 HYPERLINK Createsashortcutorjumpthatopensadocumentstoredonanetwork

    server,anintranet,ortheInternet156 INDEX Usesanindextochooseavaluefromareferenceorarray157 INDIRECT Returnsareferenceindicatedbyatextvalue158 LOOKUP Looksupvaluesinavectororarray159 MATCH Looksupvaluesinareferenceorarray160 OFFSET Returnsareferenceoffsetfromagivenreference161 ROW Returnstherownumberofareference162 ROWS Returnsthenumberofrowsinareference163 RTD RetrievesrealtimedatafromaprogramthatsupportsCOM

    automation(Automation:Awaytoworkwithanapplication'sobjectsfromanotherapplicationordevelopmenttool.FormerlycalledOLEAutomation,AutomationisanindustrystandardandafeatureoftheComponentObjectModel(COM).)

    164 TRANSPOSE Returnsthetransposeofanarray165 VLOOKUP Looksinthefirstcolumnofanarrayandmovesacrosstherowtoreturnthe

    valueofacell MathandTrigonometryFunctions Function Description

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page13 CopyrightMay2010

    166 ABS Returnstheabsolutevalueofanumber167 ACOS Returnsthearccosineofanumber168 ACOSH Returnstheinversehyperboliccosineofanumber169 ASIN Returnsthearcsineofanumber170 ASINH Returnstheinversehyperbolicsineofanumber171 ATAN Returnsthearctangentofanumber172 ATAN2 Returnsthearctangentfromxandycoordinates173 ATANH Returnstheinversehyperbolictangentofanumber174 CEILING Roundsanumbertothenearestintegerortothenearestmultipleof

    significance175 COMBIN Returnsthenumberofcombinationsforagivennumberofobjects176 COS Returnsthecosineofanumber177 COSH Returnsthehyperboliccosineofanumber178 DEGREES Convertsradianstodegrees179 EVEN Roundsanumberuptothenearesteveninteger180 EXP Returnseraisedtothepowerofagivennumber181 FACT Returnsthefactorialofanumber182 FACTDOUBLE Returnsthedoublefactorialofanumber183 FLOOR Roundsanumberdown,towardzero184 GCD Returnsthegreatestcommondivisor185 INT Roundsanumberdowntothenearestinteger186 LCM Returnstheleastcommonmultiple187 LN Returnsthenaturallogarithmofanumber188 LOG Returnsthelogarithmofanumbertoaspecifiedbase189 LOG10 Returnsthebase10logarithmofanumber190 MDETERM Returnsthematrixdeterminantofanarray191 MINVERSE Returnsthematrixinverseofanarray192 MMULT Returnsthematrixproductoftwoarrays193 MOD Returnstheremainderfromdivision194 MROUND Returnsanumberroundedtothedesiredmultiple195 MULTINOMIAL Returnsthemultinomialofasetofnumbers196 ODD Roundsanumberuptothenearestoddinteger197 PI Returnsthevalueofpi198 POWER Returnstheresultofanumberraisedtoapower199 PRODUCT Multipliesitsarguments200 QUOTIENT Returnstheintegerportionofadivision201 RADIANS Convertsdegreestoradians202 RAND Returnsarandomnumberbetween0and1203 RANDBETWEEN Returnsarandomnumberbetweenthenumbersyouspecify204 ROMAN Convertsanarabicnumeraltoroman,astext

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page14 CopyrightMay2010

    205 ROUND Roundsanumbertoaspecifiednumberofdigits206 ROUNDDOWN Roundsanumberdown,towardzero207 ROUNDUP Roundsanumberup,awayfromzero208 SERIESSUM Returnsthesumofapowerseriesbasedontheformula209 SIGN Returnsthesignofanumber210 SIN Returnsthesineofthegivenangle211 SINH Returnsthehyperbolicsineofanumber212 SQRT Returnsapositivesquareroot213 SQRTPI Returnsthesquarerootof(number*pi)214 SUBTOTAL Returnsasubtotalinalistordatabase215 SUM Addsitsarguments216 SUMIF Addsthecellsspecifiedbyagivencriteria217 SUMPRODUCT Returnsthesumoftheproductsofcorrespondingarraycomponents218 SUMSQ Returnsthesumofthesquaresofthearguments219 SUMX2MY2 Returnsthesumofthedifferenceofsquaresofcorrespondingvaluesintwo

    arrays220 SUMX2PY2 Returnsthesumofthesumofsquaresofcorrespondingvaluesintwoarrays221 SUMXMY2 Returnsthesumofsquaresofdifferencesofcorrespondingvaluesintwo

    arrays222 TAN Returnsthetangentofanumber223 TANH Returnsthehyperbolictangentofanumber224 TRUNC Truncatesanumbertoaninteger StatisticalFunctions Function Description225 AVEDEV Returnstheaverageoftheabsolutedeviationsofdatapointsfromtheir

    mean226 AVERAGE Returnstheaverageofitsarguments227 AVERAGEA Returnstheaverageofitsarguments,includingnumbers,text,andlogical

    values228 BETADIST ReturnsthebetacumulativedistributionFunction229 BETAINV ReturnstheinverseofthecumulativedistributionFunctionforaspecified

    betadistribution230 BINOMDIST Returnstheindividualtermbinomialdistributionprobability231 CHIDIST Returnstheonetailedprobabilityofthechisquareddistribution232 CHIINV Returnstheinverseoftheonetailedprobabilityofthechisquared

    distribution233 CHITEST Returnsthetestforindependence234 CONFIDENCE Returnstheconfidenceintervalforapopulationmean235 CORREL Returnsthecorrelationcoefficientbetweentwodatasets236 COUNT Countshowmanynumbersareinthelistofarguments

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page15 CopyrightMay2010

    237 COUNTA Countshowmanyvaluesareinthelistofarguments238 COUNTBLANK Countsthenumberofblankcellswithinarange239 COUNTIF Countsthenumberofnonblankcellswithinarangethatmeetthegiven

    criteria240 COVAR Returnscovariance,theaverageoftheproductsofpaireddeviations241 CRITBINOM Returnsthesmallestvalueforwhichthecumulativebinomialdistributionis

    lessthanorequaltoacriterionvalue242 DEVSQ Returnsthesumofsquaresofdeviations243 EXPONDIST Returnstheexponentialdistribution244 FDIST ReturnstheFprobabilitydistribution245 FINV ReturnstheinverseoftheFprobabilitydistribution246 FISHER ReturnstheFishertransformation247 FISHERINV ReturnstheinverseoftheFishertransformation248 FORECAST Returnsavaluealongalineartrend249 FREQUENCY Returnsafrequencydistributionasaverticalarray250 FTEST ReturnstheresultofanFtest251 GAMMADIST Returnsthegammadistribution252 GAMMAINV Returnstheinverseofthegammacumulativedistribution253 GAMMALN ReturnsthenaturallogarithmofthegammaFunction,(x)254 GEOMEAN Returnsthegeometricmean255 GROWTH Returnsvaluesalonganexponentialtrend256 HARMEAN Returnstheharmonicmean257 HYPGEOMDIST Returnsthehypergeometricdistribution258 INTERCEPT Returnstheinterceptofthelinearregressionline259 KURT Returnsthekurtosisofadataset260 LARGE Returnsthekthlargestvalueinadataset261 LINEST Returnstheparametersofalineartrend262 LOGEST Returnstheparametersofanexponentialtrend263 LOGINV Returnstheinverseofthelognormaldistribution264 LOGNORMDIST Returnsthecumulativelognormaldistribution265 MAX Returnsthemaximumvalueinalistofarguments266 MAXA Returnsthemaximumvalueinalistofarguments,includingnumbers,text,

    andlogicalvalues267 MEDIAN Returnsthemedianofthegivennumbers268 MIN Returnstheminimumvalueinalistofarguments269 MINA Returnsthesmallestvalueinalistofarguments,includingnumbers,text,and

    logicalvalues270 MODE Returnsthemostcommonvalueinadataset271 NEGBINOMDIST Returnsthenegativebinomialdistribution272 NORMDIST Returnsthenormalcumulativedistribution273 NORMINV Returnstheinverseofthenormalcumulativedistribution

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page16 CopyrightMay2010

    274 NORMSDIST Returnsthestandardnormalcumulativedistribution275 NORMSINV Returnstheinverseofthestandardnormalcumulativedistribution276 PEARSON ReturnsthePearsonproductmomentcorrelationcoefficient277 PERCENTILE Returnsthekthpercentileofvaluesinarange278 PERCENTRANK Returnsthepercentagerankofavalueinadataset279 PERMUT Returnsthenumberofpermutationsforagivennumberofobjects280 POISSON ReturnsthePoissondistribution281 PROB Returnstheprobabilitythatvaluesinarangearebetweentwolimits282 QUARTILE Returnsthequartileofadataset283 RANK Returnstherankofanumberinalistofnumbers284 RSQ ReturnsthesquareofthePearsonproductmomentcorrelationcoefficient285 SKEW Returnstheskewnessofadistribution286 SLOPE Returnstheslopeofthelinearregressionline287 SMALL Returnsthekthsmallestvalueinadataset288 STANDARDIZE Returnsanormalizedvalue289 STDEV Estimatesstandarddeviationbasedonasample290 STDEVA Estimatesstandarddeviationbasedonasample,includingnumbers,text,and

    logicalvalues291 STDEVP Calculatesstandarddeviationbasedontheentirepopulation292 STDEVPA Calculatesstandarddeviationbasedontheentirepopulation,including

    numbers,text,andlogicalvalues293 STEYX Returnsthestandarderrorofthepredictedyvalueforeachxinthe

    regression294 TDIST ReturnstheStudent'stdistribution295 TINV ReturnstheinverseoftheStudent'stdistribution296 TREND Returnsvaluesalongalineartrend297 TRIMMEAN Returnsthemeanoftheinteriorofadataset298 TTEST ReturnstheprobabilityassociatedwithaStudent'sttest299 VAR Estimatesvariancebasedonasample300 VARA Estimatesvariancebasedonasample,includingnumbers,text,andlogical

    values301 VARP Calculatesvariancebasedontheentirepopulation302 VARPA Calculatesvariancebasedontheentirepopulation,includingnumbers,text,

    andlogicalvalues303 WEIBULL ReturnstheWeibulldistribution304 ZTEST Returnstheonetailedprobabilityvalueofaztest TextFunctions Function Description305 ASC Changesfullwidth(doublebyte)Englishlettersorkatakanawithina

    characterstringtohalfwidth(singlebyte)characters

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page17 CopyrightMay2010

    306 BAHTTEXT Convertsanumbertotext,usingthe(baht)currencyformat307 CHAR Returnsthecharacterspecifiedbythecodenumber308 CLEAN Removesallnonprintablecharactersfromtext309 CODE Returnsanumericcodeforthefirstcharacterinatextstring310 CONCATENATE Joinsseveraltextitemsintoonetextitem311 DOLLAR Convertsanumbertotext,usingthe$(dollar)currencyformat312 EXACT Checkstoseeiftwotextvaluesareidentical313 FIND,FINDB Findsonetextvaluewithinanother(casesensitive)314 FIXED Formatsanumberastextwithafixednumberofdecimals315 JIS Changeshalfwidth(singlebyte)Englishlettersorkatakanawithinacharacter

    stringtofullwidth(doublebyte)characters316 LEFT,LEFTB Returnstheleftmostcharactersfromatextvalue317 LEN,LENB Returnsthenumberofcharactersinatextstring318 LOWER Convertstexttolowercase319 MID,MIDB Returnsaspecificnumberofcharactersfromatextstringstartingatthe

    positionyouspecify320 PHONETIC Extractsthephonetic(furigana)charactersfromatextstring321 PROPER Capitalizesthefirstletterineachwordofatextvalue322 REPLACE,

    REPLACEBReplacescharacterswithintext

    323 REPT Repeatstextagivennumberoftimes324 RIGHT,RIGHTB Returnstherightmostcharactersfromatextvalue325 SEARCH,

    SEARCHBFindsonetextvaluewithinanother(notcasesensitive)

    326 SUBSTITUTE Substitutesnewtextforoldtextinatextstring327 T Convertsitsargumentstotext328 TEXT Formatsanumberandconvertsittotext329 TRIM Removesspacesfromtext330 UPPER Convertstexttouppercase331 VALUE Convertsatextargumenttoanumber ExternalFunctions Function Description332 EUROCONVERT Convertsanumbertoeuros,convertsanumberfromeurostoaeuro

    membercurrency,orconvertsanumberfromoneeuromembercurrencytoanotherbyusingtheeuroasanintermediary(triangulation)

    333 SQL.REQUEST Connectswithanexternaldatasourceandrunsaqueryfromaworksheet,thenreturnstheresultasanarraywithouttheneedformacroprogramming

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page18 CopyrightMay2010

    Chapter2

    The=IFFunction

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page19 CopyrightMay2010

    =IFThe IF function is the most powerful of all functions not just in Excel, but in anyprogramming language. Commonly referred to as Conditional Programming, it is the IFfunction thatenablesus to introduce logical thinking intoanyprogram.This function isalsoreferredtoastheIfThenElsecommand,conditionalexpressions,orPropositionalLogic.ThefollowingWikisexplainsthisconceptinmoredetail:

    http://en.wikipedia.org/wiki/Conditional_(programming).http://en.wikipedia.org/wiki/Logical_conditional#Conditional_statements

    ThecleverCPAcanusetheIFFunctiontobuildelaborateExceltemplatesandfinancialmodelscontaining an almost unlimited amount of sophisticated programming. Presented below areseveralexamplestohelpyoubetterunderstandtheapplicationofthispowerfultool.SimpleIFTheIFfunctionreturnsonevalueifaconditionyouspecifyevaluatestoTRUE,andanothervalueifthatconditionevaluatestoFALSE.Presentedbelowisasimpleexample:

    SimpleIFwithCalculationPresentedbelowisanexamplethatisalittlemorecomplex:

    SimpleIFLargerExamplePresentedbelowisyetanotherIFexampleonalittlelargerscalethis example shows how onemight apply the IF function to evaluate budget versus actualcomparisons.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page20 CopyrightMay2010

    SimpleIFwithDropDownInthefollowingexample,theIFfunctionischeckingtoseeiftheyhavesignedupforinsurance.Iftheyhave,thedeductionamountisentered.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page21 CopyrightMay2010

    Simple IF with Calculation The next IF function example is determining each employeesearnedvacationdays.Iftheyhaveworkedformorethanayear,theyhaveearned5vacationdaysplusonedayforeachadditionalfullyear.

    NestedIFFunctionsInthissample,therearefourpossibilitiesforbonuses.

    IFFunctionwithLogicalORArgumentTeamsAandCmeetonTuesday,TeamsBandDmeetonThursday.WewanttolistthemeetingdaysincolumnD.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page22 CopyrightMay2010

    More Complex IF Function Example The following IF example shows a more complexapplication in which the user selects a taxpayer status from a drop down list, which thenretrievesthecorrecttaxbase,threshold,andincrementaltaxratestobeusedincalculatingtax.This example illustrates how a CPA might prepare an income statement template thatcalculates the appropriate amountof taxes asnet income and the taxpayer status changes.Essentiallythetemplatecalculatesthecorrecttaxgivenallfourpossibletaxpayerstatuses,andtheIFstatementsareusedtoselectthecorrectanswersbasedonthetaxpayerstatusselected.

    Keepinmindthatdespitethemanyaccoladesmentionedabove,theIFFunctionisnotalwaysthebestsolution.Forexample,theVLOOKUPwouldbeabetterandeasierfunctiontousetoextractdatafroma listasshown inthenestedIFFunctionafewexamplesabove.ManyExcelFunctionsalsoprovidebuiltinIFThenElsefunctionality.KeyPointersforUsingtheIFFunction:

    1. NestingYoucanembedupto8nestedIFfunctionsinasingleformulainExcel2003,andupto64IFnestedfunctionsinExcel2007.

    2. AND,ORYoucanusetheANDand/orORoperatortoaddmoreconditionstoanIFFunction.3. Variations of IF Excel offers several variations of the IF function as follows: COUNTIF,

    COUNTIFS,SUMIF,SUMIFS.4. EvaluatinganIFErrorSincethe IFstatementprovidesonlyatrueorfalseresult,there isno

    waytoevaluateanIFFunctiontoERROR.Ifyoureceiveanerror,youwrotetheformulawrong.5. TheNullSet TheDoubleQuotes is theNull Set,orabsenceofa value. Forexample,when

    testingforaZerobalanceortestingforablankcell,thefollowingIFfunctionswouldapply:a. =IF(A1=0,ZERO,)b. =IF(A1=,Blank,)(ExcelalsoprovidesanISBLANKFunctionthatwouldalsowork.)

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page23 CopyrightMay2010

    Chapter3

    UsingFunctionsToCrunch&CleanData

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page24 CopyrightMay2010

    CleaningDataUsingFunctionsCPAsoftenreceiveorretrievedatafrommanysourcesinawidevarietyofformatssuchasTextorCSVformats.Youdon'talwayshavecontrolovertheformatandtypeofdatathatyouimportfrom an externaldata source, such as adatabase, text file,or aWebpage.Before you cananalyzethedata,youoftenneedtocleanitup.Fortunately,OfficeExcelhasmanyfeaturestohelpyougetdata inthepreciseformatthatyouwant.Sometimes,thetask isstraightforwardandthereisaspecificfeaturethatdoesthejobforyou.Forexample,you caneasilyuseSpellChecker to cleanupmisspelledwords in columns thatcontaincommentsordescriptions.Or,ifyouwanttoremoveduplicaterows,youcanquicklydothisbyusingtheRemoveDuplicatesdialogbox.Atothertimes,youmayneedtomanipulateoneormorecolumnsbyusingaformulatoconverttheimportedvaluesintonewvalues.Forexample,ifyouwanttoremovetrailingspaces,youcancreateanewcolumntocleanthedatabyusingaformula,fillingdownthenewcolumn,convertingthatnewcolumn'sformulastovalues,and thenremoving theoriginalcolumn.Excelprovidesmany functions tohelpyoucleanyourdataasfollows:

    1. Import2. TexttoColumns3. RemoveDuplicates4. Find&Replace5. SpellCheck6. =UPPER7. =LOWER8. =PROPER9. =FIND

    10. =SEARCH11. =LEN12. =SUBSTITUTE13. =REPLACE14. =LEFT15. =MID16. =RIGHT17. =VALUE18. =CONCATENATE

    19. =TEXT20. =TRIM21. =CLEAN22. =FIXED23. =DOLLAR24. =CODE25. Macros

  • 1. ImportingData intoExcelOfcourseexcelopensupexcelfiles,butwhathappenswhenyouattempttoopendatathatisnotcontainedinanExcelformat?TheansweristhatExcelautomatically imports that data on the fly and displays a Import Wizard to help youcompletetheprocess.TheTextImportWizardexaminesthetextfilethatyouareimportingandhelpsyouimportthedatathewaythatyouwant.TostarttheTextImportWizard,ontheDatatab,intheGetExternalDatagroup,clickFromText.Then,intheImportTextFiledialogbox,doubleclickthetextfilethatyouwantto import.Thefollowingdialogboxwillbedisplayed:

    If items in the text file are separated by tabs, colons, semicolons, spaces, or othercharacters,selectDelimited. Ifallofthe items ineachcolumnarethesame length,selectFixedwidth.Instep3,clicktheAdvancedbuttontospecifythatoneormorenumericvaluesmaycontainatrailingminussign.Alsoclickthedesireddataformatforeachcolumntobeimported.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page26 CopyrightMay2010

    2. TexttoColumnsTheTexttoColumnscommandlocatedontheDataRibbonworksexactlythesamewayasdescribedabove theusersimply launches it toconvertdatawithinanexistingworksheet.

    3. RemovingDuplicateRowsDuplicaterowsareacommonproblemwhenyouimportdata.You can identify and remove duplicate rows by using theData,Advanced Filter,UniqueRecordsOnlytoolasshowinthescreenbelow.

    4. FindandReplaceTextThistoolcanbeusedtoidentifyandremoveleadingstring,suchasalabelfollowedbyacolonandspace,orasuffix,suchasaparentheticphraseattheendofthestringthatisobsoleteorunnecessary.Youcandothisbyfindinginstancesofthattextandthenreplacingitwithnotextorothertext.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page27 CopyrightMay2010

    NoteworthyFindandReplacePoints:

    1. Youcansearchandreplaceforanentireworksheet,ortheentireworkbook.2. Youcanfindandreplaceformatswithnewformats.3. Thereisacellchooseroptionthatmakesiteasiertofindandreplaceformats.4. Ifyouhighlightarangeofcells,thensearchandreplaceonlysearchesandreplaces

    withinthatrangeofcells.5. Youcanreplaceallatonceoroneatatime.6. Youcouldalsofindandreplacereferencesinaformula.

    5. SpellCheckYoucanuseaspellcheckertonotonlyfindmisspelledwords,buttofindvaluesthat

    arenotusedconsistently,suchasproductorcompanynames,byaddingthosevaluestoacustomdictionary.Thespellcheckfunctionalsochecksyourgrammaraswell.

    Changing The CaseOf Text You can use one ormore of the three Case functions toconvert text to lowercase letters, such as email addresses, uppercase letters, such asproductcodes,orpropercase,suchasnamesorbooktitles.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page28 CopyrightMay2010

    6. =UPPERConvertstexttouppercaseletters.

    7. =LOWERConvertsalluppercaselettersinatextstringtolowercaseletters.

    8. =PROPERCapitalizesthefirstletterinatextstringandanyotherlettersintextthatfollowanycharacterotherthanaletter.Convertsallotherletterstolowercaseletters.

    MergingAndSplittingColumnsAcommontaskafterimportingdatafromanexternaldatasource is toeithermerge twoormorecolumns intoone,orsplitonecolumn into twoormorecolumns.Forexample,youmaywanttosplitacolumnthatcontainsafullnameintoafirstand lastname.Or,youmaywanttosplitacolumnthatcontainsanaddressfield intoseparate street, city, region, and postal code columns. The reverse may also be true.Presentedbelowarefunctionsthattohelpyouaccomplishthesetasks:

    9. =FINDUseReturnsthestartingpositionofacharacter,stringofcharactersorwordwithacell.Findiscasesensitive.

    10. =SEARCHReturnsthestartingpositionofacharacter,stringofcharactersorwordwithacell.Searchisnotcasesensitive.

    11. =LENDisplaysthelengthornumberofcharactersinacell.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page29 CopyrightMay2010

    12. =SUBSTITUTEReplacesacharacterorcharacterswithacharacterorcharactersthatyouspecify.

    13. =REPLACEReplacesacharacterorcharacterswithacharacterorcharactersthatyouspecify.

    14. =LEFTExtractsthespecifiednumberofcharactersfromacell,startingfromtheleft.

    15. =MIDExtractsthespecifiednumberofcharactersfromacell,startingfromsomewhereinthemiddleofthecell.

    16. =RIGHTExtractsthespecifiednumberofcharactersfromacell,startingfromtheright.

    17. =ValueConvertstexttovaluessothedatacanbeadded,subtracted,multiplied,dividedorreferencedinafunction.

    18. =CONCATENATEJoinstwoormoretextstringsintoonetextstring.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page30 CopyrightMay2010

    Variationsofthesefunctionsthatareusedwhenworkingwithforeignlanguages:=FINDBUsethiswhenworkingwithforeigncharacterslikethese( "," )=SEARCHBUsethiswhenworkingwithforeigncharacterslikethese( "," )=REPLACEBUsethiswhenworkingwithforeigncharacterslikethese( "," )=LEFTBUsethiswhenworkingwithforeigncharacterslikethese( "," )=RIGHTBUsethiswhenworkingwithforeigncharacterslikethese( "," )=LENBUsethiswhenworkingwithforeigncharacterslikethese( "," )=MIDBUsethiswhenworkingwithforeigncharacterslikethese( "," )

    Cleaning Text (Removing SpacesAndNonprintingCharacters From Text) Sometimestext values contain leading, trailing, or multiple embedded space characters (Unicodecharactersetvalues32and160),ornonprintingcharacters(Unicodecharactersetvalues0to31,127,129,141,143,144,and157).Thesecharacterscansometimescauseunexpectedresultswhenyousort,filter,orsearch.Forexample,intheexternaldatasource,usersmaymaketypographicalerrorsbyinadvertentlyaddingextraspacecharacters,orimportedtextdata fromexternalsourcesmaycontainnonprintingcharacters thatareembedded in thetext. Because these characters are not easily noticed, the unexpected results may bedifficult to understand. Following is a list of functions you can use to remove theseunwantedcharacters:

    19. =TEXTConvertsavaluetotextinaspecificnumberformat.

    20. =TRIMRemovesthe7bitASCIIspacecharacter(value32)fromtext.

    21. =CLEANRemovesthefirst32nonprintingcharactersinthe7bitASCIIcode(values0through31)fromtext.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page31 CopyrightMay2010

    22. =FIXEDRoundsanumbertothespecifiednumberofdecimals,formatsthenumberindecimalformatbyusingaperiodandcommas,andreturnstheresult.

    23. =DOLLARConvertsanumbertotextformatandappliesacurrencysymbol.

    24. =CODEReturnsanumericcodeforthefirstcharacterinatextstring.FixingDatesandTimesTherearemanydifferentdateformats,andthesevariedformatsmaybe confusedwithnumberedpart codesorother strings that contain slashmarksorhyphens,datesandtimesoftenneedtobeconvertedandreformatted.Presentedbelowisalistoffunctionsthathelpyouaccomplishthistask.

    25. =DATE Returnsthesequentialserialnumberthatrepresentsaparticulardate. Ifthecell formatwasGeneralbeforethefunctionwasentered,theresultisformattedasadate.

    26. =DATEVALUEConvertsadaterepresentedbytexttoaserialnumber.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page32 CopyrightMay2010

    27. =TIME Returns thedecimalnumber foraparticular time. If thecell formatwasGeneralbeforethefunctionwasentered,theresultisformattedasadate.

    28. =TIMEVALUE Returnsthedecimalnumberof thetimerepresentedbyatextstring.Thedecimalnumber is a value ranging from 0 (zero) to 0.99999999, representing the timesfrom0:00:00(12:00:00AM)to23:59:59(11:59:59P.M.).TransformingAndRearrangingColumnsAndRows Mostof theanalysisand formattingfeatures inOfficeExcelassumethatthedataexists inasingle,flattwodimensionaltable.Sometimesyoumaywant tomake the rowsbecome columns,and the columnsbecomerows.Atothertimes,dataisnotevenstructuredinatabularformat,andyouneedawaytotransformthedatafromanontabulartoatabularformat.Thefollowingfunctioncanhelpyouachievethisgoal:

    29. =TRANSPOSEReturnsaverticalrangeofcellsasahorizontalrange,orviceversa.

    30. DataFill InTrickA clever trick for filling inmissingdata canbeaccomplishedusing theGOTO,Special,Blankscommand.Hereishowitworks.Thistrickworkswellwhenyouhavealargevolumeofdatabutdescriptionsarenotprovidedforeveryrow,asshownintheexamplebelow:

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page33 CopyrightMay2010

    Startbyenteringasimpleformulareferencingthedatalabelintheabovecell,justlikethis:

    a. Nextcopythatformula...b. HighlighttheentirerangecontainingdatalabelsincolumnsAandB.columns...c. PresstheF5keytolaunchtheGoTodialogbox...d. SelecttheOptionsBox...e. ClickontheBlanksradiobutton...f. PressEnter...g. Paste.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page34 CopyrightMay2010

    Thisactionwillcausealldatalabelstorepeatintheemptycellsbeneath.Next:

    h. CopycolumnsA&B...i. PasteSpecialasvaluestoconverttheformulastotextbaseddatalabels...j. Youarenowreadytosort,filter,subtotalandpivotyourdata.

    FetchingData Occasionally,databaseadministratorsuseOfficeExcel to findandcorrectmatchingerrorswhen twoormore tables are joined. Thismight involve reconciling twotables from different worksheets, for example, to see all records in both tables or tocomparetablesandfindrowsthatdon'tmatch.

    31. =VLOOKUPSearchesforavalueinthefirstcolumnofatablearrayandreturnsavalueinthesamerowfromanothercolumninthetablearray.Forexample,considertheexamplebelowwhichusesa=VLOOKUP function tocalculate theappropriateamount of taxduebasedontheIRSrateschedule.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page35 CopyrightMay2010

    As the Income statement shown in the shaded area is updated , the resulting taxableincomeamount isreferenced inCellF13.Next,3VLOOKUPfunctionspulltheappropriaterate, base and threshold information from the rate schedule to be used in calculatingincometax.Oncecalculated,theresultingtaxisreferencedbacktotheincomestatementforthepurposesofcomputingNetincomeAftertaxes.KeypointstoConsiderwhenUsingVLOOKUP:

    a. If you are looking up based on text, the first column containing lookupvaluesmustbe sortedalphabetically indescendingorderelse itwillnotworkproperly.

    b. Ifyouarelookingupbasedontext,youmusthaveanexactmatchbetweenthelookupvalueandthetablearrayvalue.

    c. If you are lookingupbasedon values, the first column containing lookup

    valuesmustbesortednumericallyindescendingorderelseitwillnotworkproperly.

    d. If you are looking up based on values, then Excelwill choose the closestvaluewithoutgoingover.Forexample, if the lookupvalue is198,000andthe table array contains values of 100,000 and 200,000, the n excelwillchoose100,000because200,000goesoverorexceeds198,000.(ItmightbehelpfultothinkbacktotheoldBobbarkergameshowthePriceisRight.)

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page36 CopyrightMay2010

    32. =HLOOKUPSearchesforavalueinthetoprowofatableoranarrayofvalues,andthenreturnsavalueinthesamecolumnfromarowyouspecifyinthetableorarray.

    33. =INDEXReturnsavalueorthereferencetoavaluefromwithinatableorrange.TherearetwoformsoftheINDEXfunction:thearrayformandthereferenceform.

    34. =MATCH Returns the relativepositionof an item in an array thatmatches a specifiedvalue inaspecifiedorder.UseMATCH insteadofoneoftheLOOKUPfunctionswhenyouneedthepositionofaniteminarangeinsteadoftheitemitself.

    35. =OFFSETReturnsareferencetoarangethat isaspecifiednumberofrowsandcolumnsfromacellorrangeofcells.Thereferencethatisreturnedcanbeasinglecellorarangeofcells.Youcanspecifythenumberofrowsandthenumberofcolumnstobereturned.

    36. DataCleaningwithMacrosToperiodicallycleanthesamedatasource,considerrecordinga macro or writing code to automate the entire process. There are also a number ofexternaladdinswrittenbythirdpartyvendors, listed intheThirdpartyproviderssection,thatyoucanconsiderusingifyoudon'thavethetimeorresourcestoautomatetheprocessonyourown.

    37. RAND( ), RANDBETWEEN( ), ROUND( ) In Excel 2003, RANDBETWEEN is not in thestandardEXCELinstallationbutiftheanalysistoolpackisinstalledandtheaddinactivateditisanextremelyusefulfunction.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page37 CopyrightMay2010

    38. InformationalFunctionsCELL(info_type,reference) Info_type is a text value that specifies what type of cellinformation youwant. The following list shows the possible values of info_type and thecorrespondingresults.

    Info_type Returns

    "address" Referenceofthefirstcellinreference,astext.

    "col" Columnnumberofthecellinreference.

    "color" 1 if thecell is formatted incolor fornegativevalues;otherwise returns0(zero).

    "contents" Valueoftheupperleftcellinreference;notaformula.

    "filename" Filename (including full path) of the file that contains reference, as text.Returnsemptytext("")iftheworksheetthatcontainsreferencehasnotyetbeensaved.

    "format" Textvaluecorrespondingtothenumberformatofthecell.Thetextvaluesforthevariousformatsareshowninthefollowingtable.Returns""attheendof the text value if the cell is formatted in color fornegative values.Returns "()" at the end of the text value if the cell is formatted withparenthesesforpositiveorallvalues.

    "parentheses" 1 if the cell is formatted with parentheses for positive or all values;otherwisereturns0.

    "prefix" Text value corresponding to the "label prefix" of the cell. Returns singlequotationmark (') if the cell contains leftaligned text, double quotationmark (") ifthecellcontainsrightalignedtext,caret (^) ifthecellcontainscenteredtext,backslash (\) if thecellcontains fillaligned text,andempty

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page38 CopyrightMay2010

    text("")ifthecellcontainsanythingelse.

    "protect" 0ifthecellisnotlocked,and1ifthecellislocked.

    "row" Rownumberofthecellinreference.

    "type" Text value corresponding to the type of data in the cell. Returns "b" forblankifthecellisempty,"l"forlabelifthecellcontainsatextconstant,and"v"forvalueifthecellcontainsanythingelse.

    "width" Columnwidthof the cell roundedoff to an integer. Eachunitof columnwidthisequaltothewidthofonecharacterinthedefaultfontsize.

    Referencethe cell that youwant information about. If omitted, information specified ininfo_typeisreturnedforthelastcellthatwaschanged.ThefollowinglistdescribesthetextvaluesCELL returnswhen info_type is "format",and reference isa cell formattedwithabuiltinnumberformat.

    IftheMicrosoftExcelformatis CELLreturns

    General "G"

    0 "F0"

    #,##0 ",0"

    0.00 "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"

    dmmmyyorddmmmyy "D1"

    dmmmorddmmm "D2"

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page39 CopyrightMay2010

    mmmyy "D3"

    mm/dd "D5"

    h:mmAM/PM "D7"

    h:mm:ssAM/PM "D6"

    h:mm "D9"

    h:mm:ss "D8"

    Iftheinfo_typeargumentintheCELLformulais"format",andifthecellisformattedlaterwithacustomformat,thenyoumustrecalculatetheworksheettoupdatetheCELLformula.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page40 CopyrightMay2010

    ThirdPartySolutionsIncaseExcelsbuiltinfunctionsarenotsufficienttomeetyourneeds,followingisapartiallistofthirdpartyprovidersthathaveproductsthatareusedtocleandatainavarietyofways.

    Provider ProductAddinExpressLtd. AdvancedFind&Replace,MergeCellsWizardAddIns.com DuplicateFinderAddinTools AddinToolsAssistCDX ZipStreamClick2Convert ConvertsPDFtoExcelformatsDigDB AddinsforExcelJKPApplicationDevelopment FlexfindforExcelJWalk&Associates,Inc. PowerUtilityPakVersion7OfficeAssistanceLLC SimilarDataFinderforExcelPATools PAToolsAdvancedFindReplacePDF2XL ConvertsPDFfilestoExcelFormatsSpinnakerSoftwareSolutions SpinnakerDBtoolsforExcelVonnix ExcelPowerExpander4.6WinPure ListCleanerLiteListCleanerProCleanandMatch2007

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page41 CopyrightMay2010

    Chapter4

    DataCommandsTheHeart&SoulOfExcel

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page42 CopyrightMay2010

    TheDataMenuPerhapsthepartsofExcelthatareofmostvaluetoCPAs,butleastusedbyCPAsaretheDatacommandsfoundundertheDatamenuinExcel2003andearlier,andon the data Ribbon in Excel 2007. These commands are shown below, and we willconcentratethenexthourtostudyingthesecommands.

    DataSort The Sort tooldoes exactlywhat it implies it sorts anddata.Key sortingpointsareasfollows:

    1. Contiguous Data The A to Z sorting tool can sort large matrix of dataautomaticallyaslongasthedataiscontiguous.Inotherwords,yourdatashouldcontainnoblankcolumns,noblank rows,and thecolumnsmustallbe labeled.OnlythenwillExcelalwayscorrectlyselecttheentirematrixforsorting.

    2. A to ZButton Simply place the cursor in the desired column for sorted, andpresstheAtoZorZtoAbuttonasthecasemaybe.Excelwillautomaticallysortallcontinuouscolumnsthathaveheadingsandallcontiguousrowsfromthetoprowunder theheading labelsdown to the lastrow in theselectedcolumn thatcontains data. (Note If you accidently select 2 cells instead of just one, yourresultswillnotbecorrect.)

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page43 CopyrightMay2010

    3. Sortby64ColumnsTheSorttoolisdramaticallyenhancedinExcel2007asitnowprovidestheabilitytosortbyupto64columns, insteadof just3columns.Presentedbelowisadialogboxwhichshowsthisexpandedfunctionality.

    4. SortLefttoRightExcelhasalwaysprovidedtheabilitytosortlefttoright.Todo

    so,selecttheoptionsbox intheSortDialogboxandclickthecheckbox labeledSortlefttoRightasshownbelow.

    5. SortbyColorExcel2007nowprovidestheabilitytosortbyfontcolororbycellcolor,orboth.This ishandy inmanyways.SometimesCPAsusecolor to tagormarkcertaincellsandlaterfinditusefultobeabletosortbythosemarkings.Inother situationsCPAsuse conditional formatting to apply color to cellsusing awidevarietyof rules.ThereafterExcelcan sort thedatabasedon the resultingcolors.Thesortbycoloroptionsareshownbelow.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page44 CopyrightMay2010

    Tobeaccurate, itwaspossibletosortbycolor inExcel2003.Toaccomplishthistask,youneededtousethe=CELLfunctioninordertoidentifyinformationabouta given cell such as the cell color or font color. Thereafter, the results of thatfunctioncouldbeusedtosortrowswhicheffectivelymeansthatyoucansortbycolorinExcel2003butittakesabitmoreeffort.

    6. SortByCustomListAnothersortingcapability inExcel istheabilitytosortbyCustomList.Forexample,assumeaCPAfirmhastenpartners,andtheManagingpartnerprefers tobe shown at the topof the list, and the remainingPartnersbased on seniority. In this case, you could create a Custom List in the excelOptionsdialogbox listingthepartners inthedesiredorder,andthensortfuturereportsbasedonthatorder.Perhapsabetterexampleuseofthisfeaturewouldbetocreateanonalphabeticcustom list of your chartof accounts, and then sort transactions to produce ageneralledgerinchartofaccountorderevenifyourpreferredchartofaccountsisnotalphabetical. thepartnersenioritydoesnotmatch thealphabeticnames,norany

    FilteringDataUsingAutoFiltertofilterdataallowsyoutoviewasubsetofyourdatainarangeofcellsortable.Onceyouhavefilteredthedata,youcanapplyadditionalfiltersto furtherrefineyourdataview.Whenyouaredone,youcancleara filter toonceagainredisplay all of the data. To use this tool, start with any list of data and turn on theAutoFiltertool.Thenpositionyourcursorinthecolumnyouwanttofilterandusethedropdownarrowstoapplyyourfiltersasshowninthescreenbelow.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page45 CopyrightMay2010

    Once the filters are applied, you will see a subset your data. For example, the screenpresentedbelowshowsfiltereddataforonlyMaconandSavannahproperties.

    Asfiltersareapplied,asmallfunnelappearsinthedropdownarrowbuttontoindicatethatafilterhasbeenapplied.Youcanapplyfiltersformultiplecolumnssimultaneously.KeyPointsConcerningTheAutoFilterCommand:

    1. ContiguousDataTheAutoFiltertoolsworksbestwhenyouareworkingwithdatathat is contiguous. Inotherwords,yourdata should containnoblank columns,noblankrows,andthecolumnsmustallbelabeled.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page46 CopyrightMay2010

    2. FilterbyMultipleColumnsYoucanfilterbymorethanonecolumn.

    3. RemovingFiltersInExcel2003andearlier,afasterwaytoremovemultiplefiltersis

    toturnofffilteringandthenturnfilteringbackon.InExcel2007youcansimpleclicktheClearbuttonintheSortandFilterGroupasshownbelow.

    4. FiltersareAdditive Eachadditionalfilter isbasedonthecurrentfilterandfurtherreducesthesubsetofdata.

    5. ThreeTypesofFiltersYoucanfilterbasedonlistvalues,byformats,orbycriteria.Eachofthesefiltertypesismutuallyexclusiveforeachrangeofcellsorcolumntable.Forexample,youcanfilterbycellcolororbyalistofnumbers,butnotbyboth;youcanfilterbyiconorbyacustomfilter,butnotbyboth.

    6. Filters Enabled A dropdown arrow means that filtering is enabled but not

    applied.

    7. FilterAppliedAFilterbutton meansthatafilterisapplied.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page47 CopyrightMay2010

    8. FilterSpanningThecommandsundertheAllDates inthePeriodmenu,suchas January or Quarter 2, filter by theperiod nomatterwhat the year. Thiscanbeuseful,forexample,tocomparesalesbyaperiodacrossseveralyears.

    9. This Year vs. YeartoDate Filtering This Year and YeartoDate aredifferent in theway that future datesarehandled.ThisYearcanreturndatesin the future for the current year,whereas Year to Date only returnsdates up to and including the currentdate.

    10. Filtering Dates All date filters arebased on the Gregorian calendar asdecreed by Pope Gregory XIII, afterwhom thecalendarwasnamed,on24February1582. TheGregorian calendarmodifies the Julian calendar's regular fouryearcycleofleapyearsasfollows:Everyyearthatisexactlydivisiblebyfourisaleapyear,except foryears thatareexactlydivisibleby100; thecenturialyears thatareexactlydivisibleby400arestill leapyears.Forexample,theyear1900 isnota leapyear;theyear2000isaleapyear.

    11. FilteringByDaysofWeekIfyouwanttofilterbydaysoftheweek,simplyformat

    thecellstoshowthedayoftheweek.

    12. Top&BottomFilteringOntheDatatab,intheSort&Filtergroup,clickFilter.PointtoNumber Filters and then selectTop10. Tofilter by number, click Items. To filter bypercentage, click Percent. Note Top andbottom values are based on the originalrangeof cellsor table columnandnot thefilteredsubsetofdata.

    13. Above&BelowAverageFiltering On theData tab, in the Sort & Filter group, clickFilter. Point to Filter byNumbers that areAbove/BelowAverage.NoteThesevaluesarebasedon theoriginal rangeof cellsortablecolumnandnotthefilteredsubsetofdata.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page48 CopyrightMay2010

    14. FilteringOutBlanksTofilterforblanks,intheAutoFiltermenuatthetopofthelist

    of values, clear (Select All), and then at the bottom of the list of values, select(Blanks).

    15. FilteringByColorSelectFilterbyColor,andthendependingonthetypeofformat,selectFilterbyCellColor,FilterbyFontColor,orFilterbyCellIcon.

    16. FilterbySelectionTofilterbytext,number,ordateortime,clickFilterbySelectedCell'sValueand then:To filterby cell color, clickFilterbySelectedCell'sColor.Tofilterby font color, click Filterby SelectedCell's FontColor. To filterby icon, clickFilterbySelectedCell'sIcon.

    17. RefreshingFiltersToreapplyafilterafterthedatachanges,clickacellintherangeortable,andthenontheDatatab,intheSort&Filtergroup,clickReapply.

    DataFormExcels2003DataFormtoolmakesExcellookmoreandbehavemorelikeadatabase,suchasMicrosoftAccess.(TheFormbuttonhasnotbeenincludedontheOfficeFluentuserinterfaceRibbon,butyoucanstilluseitinOfficeExcel2007byaddingtheFormbuttontotheQuickAccessToolbar.)

    A data form provides a convenient means to enter or display one complete row ofinformationinarangeortablewithoutscrollinghorizontally.Youmayfindthatusingadataformcanmakedataentryeasierthanmovingfromcolumntocolumnwhenyouhavemorecolumnsofdatathancanbeviewedonthescreen.Useadataformwhenasimpleformof

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page49 CopyrightMay2010

    text boxes that list the column headings as labels is sufficient and you don't needsophisticatedorcustomformfeatures,suchasalistboxorspinbutton.KeyPointsusingdataForm:

    1. Youcannotprintadataform.2. Becauseadata form isamodaldialogbox, you cannotuseeither theExcelPrint

    commandorPrintbuttonuntilyouclosethedataform.3. Youmight considerusing theWindowsPrintScreenkey tomakean imageof the

    form,andthenpasteitintoMicrosoftWordforprinting.

    Data Subtotals Excel provides an automatic subtotaling which will automaticallycalculate and insert subtotals and grand totals in your listor table.Once inserted, Excelrecalculatessubtotalandgrandtotalvaluesautomaticallyasyouenterandeditthedetaildata.TheSubtotalcommandalsooutlinesthelistsothatyoucandisplayandhidethedetailrows foreach subtotal.Examplesofa theSubtotaldialogboxanda resulting subtotaledtableareshownbelow.

    KeypointstoConsiderWhenUsingSubtotalingareasfollows:

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page50 CopyrightMay2010

    1. ContiguousDataTheSubtotal toolsworksbestwhenyouareworkingwithdata

    that is contiguous. Inotherwords,yourdata should containnoblank columns,noblankrows,andthecolumnsmustallbelabeled.

    2. Sort Before Your Subtotal Youmust sort the data by the column youwish toSubtotalby,elseyouwillreceiveerroneousresults.

    3. OtherMathematicalApplications TheSubtotaltoolnotonlycalculatessubtotals,

    but itcanalsocalculateminimums,maximums,averages,standarddeviations,andotherfunctions.

    4. Subtotalsin2007TablesExcel2007deploysSubtotalingalittledifferentlyinthattheSubtotaltoolappearsatthebottomofeachcolumn ineachtable,asshown inthescreenbelow.

    5. Automatic Outlining Subtotaling automatically inserts Outlines, which is reallycool.You can then condenseandexpand thedata in totalandby subtotal.SomeCPAs also like to copy and paste the condensed subtotal information to anotherlocationbut findthatthisprocesscopiesandpastesallofthedata.Therearetwoways to achieve a clean copy and pastewithout grabbing all the hidden data asfollows:

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page51 CopyrightMay2010

    a. CTRLkeyHoldtheControlKeydownwhileyouindividuallyclickoneachsubtotalrow.Thiswillenableyoutocopyandpastejustthesubtotaldata.Thisapproachcanbeproblematicbecauseifyoumisclick,youhavetostartover.

    b. SelectVisibleCellsAbetterapproach is touse theSelectVisibleCells tool.This

    toolwillselectonthedatayoucansee,afterwhichthecopyandpasteroutinewillyield the desired results. This option is better because it is faster and less errorprone.

    DataValidation

    DataValidationcanbeusedto limitthedatathatcanbeentered intoacell.Forexample,youmightwanttheusertoenteronlyvaluesbetween1%and99%.Youmightalsousethistool toenabledata input to adropdown list.Thishas two advantages in that it canbefasterandmoreaccurate. Startwith thedialogboxbelow tocreateyourdropdown listfunctionality.

    Aftermakingall thenecessary selections in thevalidation listdialogbox,yourworksheetwillbehaveasshownbelow.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page52 CopyrightMay2010

    Youcanalsoprovidemessagestodefinewhatinputyouexpectforthecell,andinstructionstohelpuserscorrectanyerrors.Forexample,inamarketingworkbook,youcansetupacelltoallowonlyaccountnumbersthatareexactlythreecharacterslong.Whenusersselectthecell,youcanshowthemamessagesuchasthisone:

    Ifusersignorethismessageandtypeinvaliddatainthecell,suchasatwodigitorfivedigitnumber, you can show them an actual errormessage. In amore advanced scenario, youmightusedatavalidationtocalculatethemaximumallowedvalueinacellbasedonavalueelsewhere intheworkbook. Inthefollowingexample,theuserhastyped$4,000 incellE7,whichexceedsthemaximumlimitspecifiedforcommissionsandbonuses.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page53 CopyrightMay2010

    If the payroll budget were to increase or decrease, the allowed maximum in E7 wouldautomaticallyincreaseordecreasewithit.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page54 CopyrightMay2010

    PivotTablesThePivotTablereporttoolprovidesaninteractivewaytosummarizelargeamountsofdata.UseshouldusethePivotTabletoolstocrunchandanalyzenumericaldataPivotTablereportsareparticularlyusefulinthefollowingsituations:

    a. Rearrangingrowstocolumnsorcolumnstorows(or"pivoting")toseedifferent

    summariesofthesourcedata.b. Filtering,sorting,grouping,andconditionallyformattingyourdata.c. Preparingconcise,attractive,andannotatedonlineorprintedreportsd. Queryinglargeamountsofdata.e. Subtotalingandaggregatingnumericdata.f. Summarizingdatabycategoriesandsubcategoriesg. Creatingcustomcalculationsandformulas.h. Expandingandcollapsinglevelsofdata.i. Drillingdowntodetailsfromthesummarydata

    Inessence,PivotTablespresentmultidimensionaldataviews to theuser thisprocess isoftenreferredtoasmodeling,datacubeanalysis,orOLAPdatacubes.TorearrangethePivotTabledata, justdraganddrop columnand rowheadings tomovedataaround.PivotTablesareagreatdataanalysistoolformanagement.IfyouhaveneverusedaPivotTablebefore, initially theconceptcanbedifficult tograsp.ThebestwaytounderstandaPivotTableistocreateablankPivotTableandthendraganddrop field names onto that blank table. Thisway youwill see the resulting pivot tablemagicallyappearanditwillhelpyoubetterunderstandtheimportantrelationshipbetweenthepivotpalletandthefieldnamelist.Lets create a simplePivotTable. StartwithanExcelworksheetdata that contains severalcolumnsofdatathedatamustincludecolumnandrowheadingsandithelpsifthedataiscontiguous. Place your cursor anywhere in the data and select PivotTable from theDatamenuinExcel2003andclickFinish;orfromtheinsertRibboninExcel2007.Thisprocessisshownbelow:Letsstartwithapageofdatasummarizingtheresultsoftaxseasonasallofthetimesheetentrieshavebeenenteredontoasingleworksheetasshownbelow.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page55 CopyrightMay2010

    Place your cursor anywhere in the data and select PivotTable from the Insert Ribbon asshownbelow:

    ForlearningpurposesletsrightmouseclickonthepivottableandselectPivotTableOptions,Display,ClassicPivotTableLayout.Yourscreenwillnowappearasfollows:

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page56 CopyrightMay2010

    I like forCPAs to learnhow tousePivotTables in thisviewbecause itvisuallyhelps themunderstandtheall importantrelationshipbettertheblankpivotpaletteandthePivotTablefieldList,bothelementsofwhichareshowninthescreenabove.To proceed, simply drag and drop field names shown on the right onto the blank Pivotpaletteshownonthe left.Witheachdrop,yourreportgrows larger.AsanalternativeyoucouldusethecheckboxesnexttofieldnamesthisfunctionalityisnewinExcel2007.AfteraddedsomedatatoyourblankPivotPalette,yourdatawilllooksomethinglikethis:

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page57 CopyrightMay2010

    NextformatandfilterthePivotReport.Veryquicklyyourreportcomestogetherasshownbelow.NoticethefilterbuttonhasbeenappliedandaPivottablestylehasalsobeenappliedforappearance.

    Doubleclickingonanynumberinapivotreportwillautomaticallyproduceanewworksheetcompletewithallsupportingdetailthatcomprisesthesummarynumber.ThereareamultitudeofPivotTableoptionsthatcanbeappliedtoaltertheappearanceorbehaviorofyourPivottable.KeyPointsConcerningPivotTablesareasFollows:

    a. YoucancreateasmanyPivotReportsasyouwantfromyourinitialrawdatapage.Yourraw

    dataremainsunchangedasnewPivottablesarecreated.

    b. As your rawdata changes, yourpivot tablesareupdatedeach time youpress the refreshbutton. Or if you prefer you can set your PivotTables to update themselves at regularlyscheduledintervalssayeverytenminutes.

    c. A key to understanding PivotTables is understanding the relationship between the BlankPivotpaletteand thePivotTableField list.Asdata is selected in the list, itappearson thePivottableReport.

    d. You canalter thePivotTable simplebydragginganddropping the fieldnames indifferentlocationsonthePivotpalette,orindifferentlocationsinthePivotTableFieldlistBox.

    e. PivotTablescanbepivoted.

    f. PivotTablescanbesortedbyanyColumn.(Orbyanyrowwhensortinglefttoright)

    g. PivotTablescanbeFiltered.

    h. PivotTablescanbeDrilled.

    i. PivotTablescanbecopiedandpasted.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page58 CopyrightMay2010

    j. PivotTablescanbeformattedusingPivotTableStyles,asshownbelow.

    k. Subtotalsandgrandtotalscanbedisplayedorsuppressedattheusersdesire.

    l. PivotTableDatacanbeshownasnumbersorpercentagesattheusersdesire.

    m. PivotTablecannotonlybesummed,itcanbeaveraged,minimized,maximized,counted,etc.

    n. Blankrowscanbedisplayedorsuppressedattheusersdesire.

    o. A new feature called Compact Form organized multiple column labels into a neatlyorganizedoutlinewhichiseasiertoread.

    p. PivotTablescanquerydatadirectlyfromanyODBCcompliantdatabase.ThePivotTabletoolforaccomplishingthistaskisnotincludedintheribbonyouwillfinditbyCustomizingtheQuickAccessToolBarandsearchingtheCommandsNotShown intheRibbontabtofindthePivotTableandPivotChartWizardOption.

    q. Many accounting systems can push data out of the accounting system into an ExcelPivotTableformatthis iscommonlyreferredtoasanOLAPDataCube.OLAPdataCube isjustafancywordforPivotTableandthereisnodifference.

    r. PivotTablescanautomaticallycombinedatafrommultipledatasources.ThePivotTabletoolforaccomplishingthistaskisnotincludedintheribbonyouwillfinditbyCustomizingtheQuickAccessToolBarandsearching theCommandsNotShown in theRibbontab to findthePivotTableandPivotChartWizardOption.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page59 CopyrightMay2010

    s. Excel also provides a PivotChart functionwhichworks similarly to PivotTables. PresentedbelowisanexamplePivotChart.

    Excel2003PivotTablesworkverysimilarlyasshownbelow.ExcelcreatesablankPivotTable,andtheusermustdraganddropthevarious fields fromthePivotTableFieldListontotheappropriatecolumn, row,ordatasection.Asyoudraganddrop these items, theresultingreportisdisplayedonthefly.HereistheblankPivotPaletteview.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page60 CopyrightMay2010

    Now drag and drop field names from the Pivot Table field list onto the Pivot pallet. Thisactionwillautomatically createPivotTable reports and theywill changeeach time youdropadditional fieldnames,ormove fieldnamesaround.Presentedbelowarebuta fewexamplesofhundredsofpossible reports thatcouldbeviewedwith thisdata through thePivotTableformat.

    This report shown above shows the total resulting sales foreachmarketing campaign foreachofthe4monthsmarketingcampaignswereconducted.

    In this screenwe see the same information is shown as apercentageof the total.A fewobservations include the fact that overall Radio Spots are the most profitable type ofcampaign, but only in April and July. In January and October, local ads and directmail,respectively,producebetterresults.Further,Aprilcampaignshadthebestresponseoverall.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page61 CopyrightMay2010

    Furtheranalysisinthescreenabovetellsusthatourresultsvarywidelyfromonecitytothenext. In New York, coupons were least effective, but coupons were most effective inColumbus. Pivot charts based on PivotTable data can be modified by pivoting and/ornarrowing the data. They can also be published on the Internet (or on an Intranet) asinteractiveWebpages.Thisallowsuserstoplaywiththedata.Thechartbelowprovidesavisuallookatthedatashownabove.

    FilteringPivotTablesIfyoutakeacloselookatyourresultingpivottables,youwillnoticethatExcelautomaticallyinsertsafilterbuttononeachfieldlistasshownbythedropdownarrowsinthescreenbelow:

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page62 CopyrightMay2010

    Thisdropdown filter listmakes iteasy to refine your report to include just thedata youwant.Drilling Pivot Tables Another nice feature in pivot tables is that they are automaticallydrillable.Simplydoubleclickonanynumber inapivotreporttophaveExcelautomaticallyinsertanewsheetandproducethedetailedreportunderlyingthenumberyouclickedon.Anexampleofthisisshownbelow:

    Pivot TableOptions By rightmouse clicking on your pivot table youwill reveal severaloptionsettingsboxesasshownbelow.Forexample,theseoptionsboxescontrolthetypesofsubtotalsproducedinyourpivotreports.Excelalsooffersapivottableoptionsboxaswellasalayoutwizardthatmakesproducingpivottablesalittleeasier.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page63 CopyrightMay2010

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page64 CopyrightMay2010

    DataTable(WhatifAnalysis)Datatablesarepartofasuiteofcommandsthatarecalledwhatifanalysistools.Whenyouusedatatables,youaredoingwhatifanalysis.Whatifanalysisistheprocessofchangingthe values in cells to see how those changeswill affect the outcome of formulas on theworksheet.Forexample,youcanuseadatatabletovarythe interestrateandterm lengththatareusedinaloantodeterminepossiblemonthlypaymentamounts.ThreecategoriesofWhatifAnalysisToolsTherearethreekindsofwhatifanalysistoolsinExcel:

    1. DataTables2. GoalSeek3. Scenarios

    Adata table cannotaccommodatemore than two variables. If youwant toanalyzemorethan twovariables,youshould insteadusescenarios.Although it is limited toonlyoneortwovariables(onefortherowinputcellandoneforthecolumninputcell),adatatablecanincludeasmanydifferentvariablevaluesasyouwant.Ascenariocanhaveamaximumof32differentvalues,butyoucancreateasmanyscenariosasyouwant.LoanAnalysisInthisexercise,westartbycreatingasimplePaymentfunctiontocalculatethepaymentamountofaloangivenaloanamount,interestrateandnumberofperiods.

    ThenextstepistocreateaTwoWayDataTabledisplayingtheresultingpaymentamountgiven a variety of lengths of the loan. This process is started by creating a list of thealternative loanamounts,asshownbelow inB8,B9,B10,etc.CellC7mustreference theresultsyouwanttobedisplayedinthetable.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page65 CopyrightMay2010

    ThenextstepistohighlightthedatatablerangeandusetheDataTablecommandundertheDatamenu(asshownbelow)togeneratethedesiredtable.

    Thisprocesswillgeneratethefollowingtable:

    Thistabletellsusthatthesameloanamountwillrequireamonthlypaymentof$3,331topaytheloanoffinjust10years,andamonthlypaymentof$5,800torepaytheloaninjust5years.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page66 CopyrightMay2010

    Thenextstepinthisexerciseistogeneratealinechartbasedonthedatatablewejustcreated.Thislinechartwillprovidesomeinterestingobservationsregardingthebenefitsanddetrimentsofpayingoffloansoverlongerperiods.

    Theresultingchartisshownasfollows:

    Basedon this,noone shouldeverobtaina fairmarket loan formore than15years, thereductioninpaymentssimplyarentworththeadditionallengthoftheloan.Thissamebasicbehavior is seenwhether the interest rate is 1% or 100%. The only time youmight be

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page67 CopyrightMay2010

    justified in obtaining a loan loner than 15 years might be when you are extended afavorableinterestthisbetterthanafairmarketinterestrate.Goal Seek Ifyouknowtheresultthatyouwantfromaformula,butarenotsurewhatinputvaluetheformulaneedstogetthatresult,usetheGoalSeekfeature.Forexample,supposethatyouneedtoborrowsomemoney.Youknowhowmuchmoneyyouwant,howlongyouwanttotaketopayofftheloan,andhowmuchyoucanaffordtopayeachmonth.YoucanuseGoalSeek todeterminewhat interest rateyouwillneed to secure inorder tomeetyour loangoal.GoalSeekworksonlywithonevariable inputvalue.Ifyouwanttoacceptmorethanoneinputvalue;forexample,boththeloanamountandthemonthlypaymentamountforaloan,youusetheSolveraddindiscussedattheendofthismanual.Scenarios ScenarioManagerallowsyoutocreateandsavemultiplewhat ifscenarios(suchasbestcase,most likely,andworstcasesscenarios).Youcanalsocreateasummary tableof thescenarioresultsinseconds.Itisparticularlyusefulforworksheetssuchasbudgetsinwhichusers have often savedmultiple copies of the sameworksheet to accomplish the sameobjective. An example is shown below. In this example, a tire company has prepared arevenue budget for the coming year, and has created three alternative scenarios togeneratetherevenuesthatwillresultgivenavarietyofmarkupassumptionsinthiscase100%,110%and120%markups.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page68 CopyrightMay2010

    Pressingthesummarybutton inthescenariomanagerdialogboxwillcreatethefollowingPivotTableofpossiblealternativeresults.Hereweseedetailedrevenueprojectionsforalltiresandlaborfeesgivenallthreepossiblescenariosof100%,110%,and120%markup.

    Witha few simple copypaste commands, thenewly createddata canbepositionedandformattednexttotheoriginalprojectionsasshowninthescreenbelow.

    Ofcoursethescenariosabovecouldhavebeencreatedeasilyusingsimpleformulasinsteadofusingthescenariomanagertoolasdescribedabove.Thisunderscoresthatbestpurposeofscenariomanagerwhichistokeeptrackofolderandchangingdatathroughtime,ratherthanproducingwhatifscenarios.Forexample,acomplexprojectioncontainingscenariosbased on original assumptions, revised assumptions, and final assumptions will allowmanagementtogobackandreviewtheassumptionsusedthroughouttheproject,andseehowthoseassumptionschangedasprojectplanningprogressed.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page69 CopyrightMay2010

    DataTexttoColumnsAs discussed earlier in this manual, often CPAs receive data from their clients or ITdepartmentsthatisintextform.Whenthishappens,Excelcansplitthecontentsofoneormorecellsinacolumnanddistributethosecontentsasindividualpartsacrossothercellsinadjacentcolumns.Forexample,theworksheetbelowcontainsacolumnoffullnamesandamountsthatyouwanttosplit intoseparatecolumns.TheTexttoColumnsWizardparsesthedataautomaticallyintoseparateSelect the cell, range (range: Two ormore cells on a sheet. The cells in a range can beadjacentornonadjacent.),orentirecolumnthatcontainsthetextvaluesthatyouwanttosplit.NoteArangethatyouwanttosplitcanincludeanynumberofrows,butitcanincludenomorethanonecolumn.Youalsoshouldkeepenoughblankcolumnstotherightoftheselectedcolumntopreventexistingdatainadjacent

    DataConsolidateExcelcancombine,summarize,and reportconsolidated results fromseparateworksheets.Theunderlyingworksheetscanbe in thesameworkbookor inotherseparateworkbooks.Therearetwodifferentsitautionsasfollows:

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page70 CopyrightMay2010

    1. YouAreConsolidatingSimilarDataSuchasdepartmentalbudgetswhereeveryworksheetcontainstheexactsamelabelsintheexactsamecells.Inthiscase,youcanwriteaSpearingFormulawhichcanconsolidatethenecessaryinformationeasily.

    2. YouAreConsolidatingDisSimilarDataThevariousworksheetscontaindifferentrowandcolumndescriptionslocatedindifferentlocationsontheworksheets.InthiscaseyoushouldusetheDataConsolidatecommand.

    Forexample,assumethatyouhavereceivedbudgetsfrommultipledepartments,andyouwanttocombinethemtogether.Inthiscase,Excelwilldotheworkforyou.Youcanuseaconsolidationtorollupthesefiguresintoacorporatebudgetworksheet,asshownbelow.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page71 CopyrightMay2010

    DataGrouping&OutliningIfyouhavealistofdatathatyouwanttogroupandsummarize,youcancreateanoutlineofuptoeightlevels,oneforeachgroup.Eachinnerlevel,representedbyahighernumberintheoutlinesymbolsdisplaysdetaildata fortheprecedingouter level,representedbyalowernumber in theoutline symbols.Useanoutline toquicklydisplay summary rowsorcolumns,ortorevealthedetaildataforeachgroup.Youcancreateanoutlineofrows(asshown in the example below), an outline of columns, or an outline of both rows andcolumns.

    WebQueriesExcel includespredesignedqueriesthatcan importcommonlyuseddata in10seconds.For example, you could use aweb query to create a stock portfolio. All you need is aconnection to the Internetandofcourse,somestock tickersymbols. InExcel2003selectData, Import External Data, Import Data andwalk through theweb querywizard forimportingstockquotes.InExcel2007and laterusetheDataRibbon,ExistingConnections,StockQuotesoption.Inseconds,Excelwillretrieve20minutedelayedstockpricesfromtheweb(duringthehourswhenthestockmarketisopen)anddisplayagridofcompleteuptodatestickpriceinformationthatissynchronizedtothestockmarketschangingstockprices.WitheachclickoftheRefreshbutton,thestockprice information inExcel isupdated thissurebeatspickingnumbersoutofthenewspaper.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page72 CopyrightMay2010

    CompletingtheStockPortfolioNext linkthegriddatatoanotherworksheet,and insertnewcolumnscontainingthenumberofsharesowned,aswellsasanadditionalcolumntocomputerthetotalvaluebasedonsharesowned,asshownbelow.

    RefreshingtheStockPricesOnceyouhavecreatedyourportfolio,simplyclicktheRefreshDatabuttonontheExternalDataToolbarinExcel2003orontheDataRibboninExcel2007shownbelowtoupdatethecurrentvalueofyourPortfolio.

    QueryParameters Therearenumerousoptionstohelpyouextractexactlythedatayouwanttheywayyouwant it.TheWebQueryParametersBox,WebQueryOptionsboxand External Data Properties Box provide numerous options for controlling yourwebquery.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page73 CopyrightMay2010

    DatabaseQueriesMicrosoftExcelcanalsoqueryandretrievedatayouwantfromanexternaldatasource.Forexample,youcanretrieveMicrosoftExceldataaboutaspecificproductbyregion.YoucancreateasimplequerybyusingtheQueryWizard,oryoucancreateamorecomplexquerybyusingtheadvancedfeaturesofMicrosoftQuery.TouseMicrosoftQuerytoretrieveexternaldata,youmust:

    1. HaveaccesstoanexternaldatasourceIfthedata isnotonyour localcomputer,youmayneedtoseetheadministratoroftheexternaldatabaseforapassword,userpermission,orotherinformationabouthowtoconnecttothedatabase.

    2. Install Microsoft Query IfMicrosoftQuery is not available, youmight need toinstallit.

    3. Specifyasourcetoretrievedatafrom,andthenstartusingMicrosoftQueryForexample, ifyouwantto insertdatabase information,displaytheDatabasetoolbar,clickInsertDatabase,clickGetData,andthenclickMSQuery.

    Forexample,supposewehavesomedata inouraccountingsystemSageMAS200ERPthatwewould liketoanalyze inExcel. WecanusetheDatabaseQueryWizardtobuildaquerythatwillextractthedataweneedandplaceitinanExcelspreadsheet.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page74 CopyrightMay2010

    Thefirststepistoselectthetypeofdatabaseyouwanttoqueryandtoselectthespecificdatabase.

    Upon the selectionof thedesireddatabasea listof tableswillbepresented.Choose thedesired tables,and select thedesireddata fields tobe imported.Youwill thenhave theoptiontofilterandsortthedatabeforeitisimported.Finallyyouwillbegiventheoptiontosavethequerysothatyoucanrunitatalaterdatewithouthavingtostartfromscratch.Excelwillthenreturnatablefullofthedatayourequestedasshowninthescreenbelow.

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page75 CopyrightMay2010

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page76 CopyrightMay2010

    Chapter5

    MACROSAutomatingYourKeyStrokes

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page77 CopyrightMay2010

    MacrosMacrosofferapowerfuland flexibleway toextend the featuresofExcel.Theyallow theautomation of repetitive tasks such as printing, formatting, configuring, or otherwisemanipulatingdatainExcel.Initssimplestform,amacroisarecordingofyourkeystrokes.WhilemacrosrepresentoneofthestrongerfeaturesfoundinExcel,theyarerathereasytocreateanduse.TherearesixmajorpointsthatIliketomakeaboutmacrosasfollows.

    1. Record,UseExcel,StopRecordingTocreateamacro,simplyturnonthemacrorecorder,useExcelasyounormallydo,thenturnofftherecorder.Prestoyouhavecreated a macro. While the process is simple from the users point of view,underneath the covers Excel creates aVisualBasic subroutineusing sophisticatedVisualBasicprogrammingcommands.

    2. MacroLocationMacroscanbestoredineitheroftwolocations,asfollows:

    a. Theworkbookyouareusing,orb. YourPersonalMacroWorkbook(whichbydefaultishiddenfromview)

    If your macro applies to all workbooks, then store it in the Personal MacroWorkbook so itwillalwaysbeavailable inallof yourExcelworkbooks;otherwisestoreitinyourcurrentworkbook.Amacrostoredinyourcurrentworkbookwillbeembedded and included in the workbook, even if you email the workbook toanotheruser.

    3. AssignyourMacrotoanIcon,TextoraButtonTomakeiteasytorunyourmacro,youshouldassign ittoatoolbar iconso itwillalwaysbeavailablenomatterwhichworkbooksyouhaveopen.Ifthemacroappliesonlytoyourcurrentworkbook,thenassign it to Text or amacroButton so itwill be quickly available in your currentworkbook.

    4. AbsoluteversusRelativeMacrosAnAbsolutemacrowillalwaysaffectthesamecellseachtimewhereasaRelativemacrowillaffectthosecellsrelativetowhereyour cursor is positioned when you invoke the macro. It is crucial that youunderstandthedifference.

    5. EditingMacrosOncecreated,youcanviewand/oredityourmacrousingtheViewMacrosoption.Thiswillopenthemacrosubroutine inaVisualbasicprogrammingwindowandprovideyouwithaplethoraofVBtools.

    6. AdvancedVisualBasicProgrammingFor the trulyambitiousCPA, in theVisualBasicProgrammingwindow, youhave thenecessary tools youneed tobuild verysophisticated macros with dialog boxes, drop down menu options, check boxes,

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page78 CopyrightMay2010

    radiobuttonsthewholeworks.Iinviteyoutoknockyourselfout.Toseeallofthispower,turnontheDeveloperTabinExcelOptions(seebelow).

    Presentedbelowaremoredetailedcommentsandstepbystepinstructionsforcreatingandinvokingmacros,followedbysomeexamplemacros.1. CreatingaMacroTocreateamacro,clickRecordMacrointheCodeGrouponthe

    DeveloperTab.

    a. AssignaNameIntheMacroNamebox,enteranameforthemacro.

    i. Thefirstcharacterofthemacronamemustbealetter. ii. Subsequent characters can be letters, numbers, or underscore

    characters. iii. Spacescannotbeusedinamacroname(anunderscorecharacter

    isoftenusedasawordseparator. iv. Ifyouuseamacronamethatisalsoacellreference,youmayget

    anerrormessagethatthemacronameisnotvalid.

    b. AssignaCTRLCombination(optional)YoucanassignaCTRLcombinationshortcutkey to run themacroby typingany lowercase letteroruppercaseletterthatyouwanttouseintheShortcutkeybox.

    i. The shortcut keywill override any equivalent default Excelshortcutkeywhiletheworkbookthatcontainsthemacroisopen.

    c. MacroLocationIntheStoreMacroInlist,selecttheworkbookwhere

    youwanttostorethemacro.

    i. Asmentionedabove,ifyouwantamacrotobeavailablewheneveryouuseExcel,selectPersonalMacroWorkbook.WhenyouselectPersonalMacroWorkbook,Excelcreatesahiddenpersonalmacroworkbook(Personal.xlsb)ifitdoesnotalreadyexist,andsavesthemacrointhisworkbook.

    ii. InWindowsVista,thisworkbookissavedintheC:\Users\username\AppData\Local\Microsoft\Excel\XLStartfolder.

    iii. InMicrosoftWindowsXP,thisworkbookissavedintheC:\DocumentsandSettings\username\ApplicationData\Microsoft\Excel\XLStartfolder.

    iv. WorkbooksintheXLStartfolderareopenedautomaticallywheneverExcelstarts.

    v. Ifyouwantamacrointhepersonalmacroworkbooktoberunautomaticallyinanotherworkbook,youmustalsosavethat

  • ExcelFunctions,Macros&DataCommands

    www.CarltonCollins.com Page79 CopyrightMay2010

    workbookintheXLStartfoldersothatbothworkbooksareopenedwhenExcelstarts.

    d. MacroDescriptionIntheDescriptionbox,typeadescriptionofthemacro.

    e.