Sunteți pe pagina 1din 2

3/1/2017 ExcelHelp:UsingCOUNTIF()andSUMIF()formulas,examples|Chandoo.

orgLearnMicrosoftExcelOnline

CustomSearch
Search

EightwaystoexploitCOUNTIF()andsumif()too
[spreadcheats]
PostedonNovember12th,2008inLearnExcel79comments

Ifforeverycountif()Iwriteexcelpaidmeadollar,Iwouldbeamillionairebynow.Itissuchaversatileandfun
formulatoworkwiththatIhavedecidedtowriteaboutitasthirdpostinourspreadcheatsseries.

1. UsingCOUNTIF()toreplacepivottables:Weall
knowthatyoucanusecountif()toreplacepivottablesforsimpledatasummarization.Foreg.ifyouhave
customerdatainatableandyouwouldliketoknowhowmanycustomersyouhaveineachcityyoucanuse
countif()tofindthat.
countif("masterdatarange","cityname")
Moreonthismethodofusingcountifand4otherwaysofusingexcelif()formulas
2.CountingValidPhoneNumbersinaRange:Usingoperators<and>incountif()youcanfindoutvalid
phonenumbersinrangelikethis:countif("datarange",">"&1000000000)
3.Findingnumberofcustomersinacitybasedontheirphonenumber:Thistrickmaynotwork
perfectly.Wecanusecountif("datarange","22*")tofindouttotalcustomersinMumbai(sinceallMumbai
phonenumbersbeginwith22)
Note:Thismethodworksaslongasphonenumbershaveidentifiablecallingcodesandstoredastext.To
covertanumbertotextyoucanusetext()orappendanemptyspacetothenumber.
4.Patternmatching:Oftenwhenyouextractdatafromothersourcesandpasteitinexcelitisdifficultto
processitwhentheformatsarenotconsistent.Foreg.whenyoucopyaddressdataofabunchofcustomers
andneedtoknowhowmanycustomersareinNewYorkyoucanusecountiflikethis:countif("data
range","*newyork*"),theoperator*tellsexceltomatchanycellwithnewyorkinit,notnecessarilyatthe
beginningorendofthecell.
5.Countingpositivenumbersinarange:Againweusethe>operatortocountthepositivenumbersina
rangelikethis:countif("datarange",">0").
Averygooduseofthistrickiswhenyouneedtocalculateaverageofabunchofnumbersbutneedtoexclude
zeros:sum("datarange")/countif("datarange","<>0")
6.AsareplacementtoFIND():ExcelFIND()ispowerfulformulatofindifaparticulartextoccurredin
anothertext.Butoneproblemwithfindisitreturns#value!errorifthevalueyouarelookingforisnotinthe

http://chandoo.org/wp/2008/11/12/usingcountifsumifexcelhelp/ 1/16
3/1/2017 ExcelHelp:UsingCOUNTIF()andSUMIF()formulas,examples|Chandoo.orgLearnMicrosoftExcelOnline
inputcell.Whatifallyouneedtoknowwaswhetheryourcellshadaparticularvalueornot?Youareright,
youcanuseCOUNTIF()forthattoo,like:countif("cellyouwanttolook","*hilton*")willreturn1or0.
7.Forsortingtext:Readmoreonthisatsortingtextusingexcelformulas

8. Findoutthenumberoferrorsinasheet:Thebeautyofcountif()is
thatyoucanevencounterrorcells.Foreg.youcanuseitlike:=COUNTIF(1:33,"#VALUE!")tofindouthow
many#VALUE!errorswerethereintherowsfrom1to33.Thiscanbeusefulifyouarebuildingacomplex
modelandneedtokeeptrackoferrors.

MostofthetricksshouldworkwithSUMIF()aswell.

Ifyoulikethis,readtheotherpostsinthespreadcheatsseries.Itisa30postseries(3postedsofar)thataspires
tomakeYOUverygoodinusingexceltosolvedaytodayproblems.

Sharethistipwithyourfriends

Facebook 2 LinkedIn Twitter Google Email Print

79ResponsestoEightwaystoexploitCOUNTIF()andsumif()too[spreadcheats]

1. DBrueggemansays:
November13,2008at2:31am

Chandoo
I'monofthoseLifeHackersthathaveinvadedyourblog.ImustsaythatIlovethesimplestyleyouuseI've
alreadypointedanumberofcoworkerstoyourblogforhintsandtrickstorelievemyselfofthesomeofthe
workthatcomeswithbeingtheresidentOfficeguru.
Onethingthatwouldbegreatforthisseriesisareviewofv/hlookupvs.theIndex/Matchcombination.Ican
alwaystellwhensomeonereadytogotothenextlevelwhentheydiscovervlookupbutusingthatcommand
reallypumpsupthefilesizeinolderversionsofexcel(pre'07).Index(entirerange,useMatchonthevertical
list,useMatchonthehorizontallist)issomuchmoreversatileyoucanchangetheorderofcolumns,rows,
andpickoutitemsthatareleftofthelookup.Italsoisveryeasyonthefilesize(apluswhenyouhaveto
emailfilesunderthedraconianlimitsofthemailattachmentsize.
Lookforwardtoyourfuturepostsyou'remynewestGoogleReaderfeed!

Reply

2. Chandoosays:
November13,2008at7:20pm

@DBrueggeman:Welcomeandthanksalotforthesweetwords

Iamsoooohappyyouwereabletousesomeofthisandsharingitwithothers.

Iamgoingtowriteaboutoffset/vlookupaspartofthespreadcheats,maybethisweek.Ihopesomeof
thesequestionscanbeanswered.

Reply

Chahinesays:
July28,2013at9:07am

firstwhenireadyourwebsitenameifounditfunnyithoughtwhatthatchandoocandowiththat
similarnamebutwhenicontinuereadingyourworkandfindouthowitsproandwellexplainedim
surprisedmanandbesureyouarethefirstandonlyoneinmybookmarksconcerningExcel!!
youareonefromfewpeoplesthataregivingandhelpingwithoutaskinganythinginreturn
allthebestforyouandforChandoo.org
Regards,
Chahine

Reply
3.AdvancedDataValidationTechniquesinExcelSwitchlists,changelistsetc.|PointyHairedDilbert
Chandoo.orgsays:
November25,2008at7:02pm

[...]nameandthelistissortedoncolumnB,wecanuseoffset()andmatch()combinationalongwithcountif
(ahem!)todeterminewhichrangetouseforprojectcell[...]

Reply

http://chandoo.org/wp/2008/11/12/usingcountifsumifexcelhelp/ 2/16

S-ar putea să vă placă și