VBA - Counting rows in a range | MrExcel Message Board

文章推薦指數: 80 %
投票人數:10人

Hi all, Just looking for some help. I'm looking to count the number of rows starting in a specfic cell and to the bottom of the range. Forums What'snew Newposts ExcelArticles MrExcelPublishing Login Register What'snew Search Newposts Searchforums Menu Login Register Installtheapp Install Ifyouwouldliketopost,pleasecheckouttheMrExcelMessageBoardFAQandregisterhere.Ifyouforgotyourpassword,youcanresetyourpassword. Forums QuestionForums ExcelQuestions Youareusinganoutofdatebrowser.Itmaynotdisplaythisorotherwebsitescorrectly.Youshouldupgradeoruseanalternativebrowser. VBA-Countingrowsinarange Threadstarter untitled_1 Startdate May15,2015 U untitled_1 NewMember Joined May8,2015 Messages 28 Hiall, Justlookingforsomehelp.I'mlookingtocountthenumberofrowsstartinginaspecficcellandtothebottomoftherange.ThestartoftherangewillbefixedbuttheendnumberofrowswillalwayschangesoIcan'thaveafixedrange. Range("A"&Rows.Count).End(xlUp).Row TheformulaabovecountsalloftherowsincolumnA(startinginA1tothebottomoftherows).HowcanIwriteitsoitcountsstartinginA8butstillgoestothebottomoftherange?(myendrangeisalwayschanging)   ExcelFacts Canaformulaspearthroughsheets? Clickheretorevealanswer Use=SUM(January:December!E7)tosumE7onallofthesheetsfromJanuarythroughDecember JLGWhiz Well-knownMember Joined Feb7,2012 Messages 12,979 OfficeVersion 2013 Platform Windows untitled_1said: Hiall, Justlookingforsomehelp.I'mlookingtocountthenumberofrowsstartinginaspecficcellandtothebottomoftherange.ThestartoftherangewillbefixedbuttheendnumberofrowswillalwayschangesoIcan'thaveafixedrange. Range("A"&Rows.Count).End(xlUp).Row TheformulaabovecountsalloftherowsincolumnA(startinginA1tothebottomoftherows).HowcanIwriteitsoitcountsstartinginA8butstillgoestothebottomoftherange?(myendrangeisalwayschanging) Clicktoexpand... Code: DimcntAsLong cnt=ActiveSheet.Range("A8",ActiveSheet.Cells(Rows.Count,1).End(xlUP)).Rows.Count MsgBoxcnt   U untitled_1 NewMember Joined May8,2015 Messages 28 JLGWhizsaid: Code: DimcntAsLong cnt=ActiveSheet.Range("A8",ActiveSheet.Cells(Rows.Count,1).End(xlUP)).Rows.Count MsgBoxcnt Clicktoexpand... Thatseemstoworkprettywell,thanks.   D djrod1rep NewMember Joined Apr22,2015 Messages 36 Ifyouareeliminating8rowsfromthebeginning,youcanuse: Code: Range("A"&Rows.Count).End(xlUp).Row-8   U untitled_1 NewMember Joined May8,2015 Messages 28 djrod1repsaid: Ifyouareeliminating8rowsfromthebeginning,youcanuse: Code: Range("A"&Rows.Count).End(xlUp).Row-8 Clicktoexpand... Thankyou,thatsaveryshortandneatversion   JLGWhiz Well-knownMember Joined Feb7,2012 Messages 12,979 OfficeVersion 2013 Platform Windows untitled_1said: Thatseemstoworkprettywell,thanks. Clicktoexpand... You'rewelcome, Regards,JLG   Youmustloginorregistertoreplyhere. Share: Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email Share Link Excelcontainsover450functions,withmoreaddedeveryyear.That’sahugenumber,sowhereshouldyoustart?Rightherewiththisbundle. Forumstatistics Threads 1,167,361 Messages 5,853,387 Members 431,578 Latestmember thiagomartsan Sharethispage Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email Share Link Forums QuestionForums ExcelQuestions We'vedetectedthatyouareusinganadblocker.WehaveagreatcommunityofpeopleprovidingExcelhelphere,butthehostingcostsareenormous.YoucanhelpkeepthissiterunningbyallowingadsonMrExcel.com.AllowAdsatMrExcelWhichadblockerareyouusing?DisableAdBlockFollowtheseeasystepstodisableAdBlock1)Clickontheiconinthebrowser’stoolbar.2)Clickontheiconinthebrowser’stoolbar.2)Clickonthe"Pauseonthissite"option.GobackDisableAdBlockPlusFollowtheseeasystepstodisableAdBlockPlus1)Clickontheiconinthebrowser’stoolbar.2)Clickonthetoggletodisableitfor"mrexcel.com".GobackDisableuBlockOriginFollowtheseeasystepstodisableuBlockOrigin1)Clickontheiconinthebrowser’stoolbar.2)Clickonthe"Power"button.3)Clickonthe"Refresh"button.GobackDisableuBlockFollowtheseeasystepstodisableuBlock1)Clickontheiconinthebrowser’stoolbar.2)Clickonthe"Power"button.3)Clickonthe"Refresh"button.GobackContinuewithoutadsI'vedisabledmyadblock Top



請為這篇文章評分?