Вы находитесь на странице: 1из 15

(/excel/)

Search...

E x c e l& V B A

Excel & VBA


ExcelTips(/excel/index.php?
option=com_content&view=category&id=77&Itemid=473)
ExcelFunctions(/excel/index.php?
option=com_content&view=category&id=78&Itemid=474)
ExcelVBA(/excel/index.php?
option=com_content&view=category&id=79&Itemid=475)
ExcelPivotTables(/excel/index.php?
option=com_content&view=category&id=81&Itemid=486)

VBA Tutorial Login

V B A T u to ria lL o g in

Free!ExcelVBAOnlineTutorial
ExcelTips(/excel/index.php?option=com_content&view=category&id=77&Itemid=473)
Username

"

# Password
Excel Tips
Login

Createanaccount

(/excel/index.php?option=com_users&view=registration&Itemid=)

LastForgotyourpassword?(/excel/index.php?option=com_users&view=reset&Itemid=)
used row number and cell address, last numeric or text value in column
Vote5

8
Rate

FindLastUsedRowinaColumn:

RelatedLinks:
VBACodesLastusedrowLastusedcolumn.(index.php?option=com_content&view=article&id=86:lastusedrowlastusedcolumnvba&catid=79&Itemid=475)

Table1

Formulafor'CellAddressofthelastnumericvaluewithincolumn'

=ADDRESS(MATCH(9.99999999999999E+307,A:A),COLUMN(A1))[Formula]

Theformulareturnscelladdressofthelastnumericvalueincolumn,whichis$A$10.(ReferTable1)

Theformulaworkseveniftherangecontainsblanks,errorvalues(like#N/A),andtextvalues.

9.99999999999999E+307[FormulaBreak]

ThisistheLargest+ivenumberinExcel.


=MATCH(9.99999999999999E+307,A:A)[FormulaBreak]

Thispartoftheformulareturnstherownumberofthelastnumericvalue,withincolumn,whichis10.(ReferTable1).Therangedoesn'thavetobeafull
column.YoucanuseA5:A50insteadofA:A.

MATCHseeminglylooksforanumericvalueatthebottomofthecolumn,presumingtherangeisinascendingorder,andignorestext&nonnumericvalues.
MATCHlooksfor9.99999999999999E+307inthecolumn,andintheabsenceofMatch_type0(tofindanexactmatch),itlooksforthelargestvaluethatis
less than or equal to 9.99999999999999E+307. It then determines that the last numeric in the column is the largest value that is less than or equal to
9.99999999999999E+307.

MATCHreturnstherelativepositionintheLookUpArray,ofthelastnumericvalue(viz.numericvalueatthebottomofthecolumn)whichwillobviouslybe
smallerthanorequaltothislargest.

Iftherangehasnonumericvalue,theMATCHformulawillreturnthe#N/Aerror.

Table2

Formulafor'Rownumberofthelastnumericvaluewithincolumn'

=MATCH(9.99999999999999E+307,A:A)[Formula]

Theformulareturnsrownumberofthelastnumericvalueincolumn,whichis10.(ReferTable2).Therangedoesn'thavetobeafullcolumn.Youcanuse
A5:A50insteadofA:A.

MATCHseeminglylooksforanumericvalueatthebottomofthecolumn,presumingtherangeisinascendingorder,andignorestext&nonnumericvalues.
MATCHlooksfor9.99999999999999E+307inthecolumn,andintheabsenceofMatch_type0(tofindanexactmatch),itlooksforthelargestvaluethatis
less than or equal to 9.99999999999999E+307. It then determines that the last numeric in the column is the largest value that is less than or equal to
9.99999999999999E+307.

MATCHreturnstherelativepositionintheLookUpArray,ofthelastnumericvalue(viz.numericvalueatthebottomofthecolumn)whichwillobviouslybe
smallerthanorequaltothislargest.

Theformulaworkseveniftherangecontainsblanks,errorvalues(like#N/A),andtextvalues.

Iftherangehasnonumericvalue,theMATCHformulawillreturnthe#N/Aerror.

9.99999999999999E+307[FormulaBreak]

ThisistheLargest+ivenumberinExcel.

Table3

Formulafor'Rownumberofthelasttextvalue,includingaformulablank,withincolumn'

=MATCH(REPT("z",255),A:A)[Formula]
{PresumingnoGreek,Cyrillic,Hebrew,orArabiccharactersintextvalues}

Theformulareturnsrownumberofthelasttextvalueincolumn,whichis9.(ReferTable3).Therangedoesn'thavetobeafullcolumn.YoucanuseA5:A50
insteadofA:A.

MATCHseeminglylooksforatextvalueatthebottomofthecolumn,presumingtherangeisinascendingorder,andignoresnumerics&nontextvalues.
MATCHlooksforthestringof255z'sinthecolumn,andintheabsenceofMatch_type0(tofindanexactmatch),itlooksforthelargestvaluethatisless
thanorequalto255z's.Itthendeterminesthatthelaststringinthecolumnisthelargestvaluethatislessthanorequalto255z's.

MATCHreturnstherelativepositionintheLookUpArray,ofthelasttextvalue(viz.textvalueatthebottomofthecolumn)whichwillobviouslybesmaller
thanorequaltothislargest.

Theformulaworkseveniftherangecontainsblanks,errorvalues(like#N/A),andnumericalvalues.

Iftherangehasnotextvalue,theMATCHformulawillreturnthe#N/Aerror.

=REPT("z",255)[FormulaBreak]

InExcelthisevaluatestothelargeststringvalue,consistingof255Zcharacters(zzzzzzzz......),tofindthelasttextentry.

Greek,Cyrillic,Hebrew,orArabiccharacterscomeafter"z"inthesortorder.Hencetheexclusion.

Table4

Formulafor'Lastnumericvalueincolumn'

=INDEX(A:A,MATCH(9.99999999999999E+307,A:A))[Formula]
Theformulareturnslastnumericvalueincolumn,whichis22.(ReferTable4).Therangedoesn'thavetobeafullcolumn.YoucanuseA5:A50insteadof
A:A.
INDEXReturnsthenumericvalueinthearrayselectedbytherownumberindex.Rownumberis"=MATCH(9.99999999999999E+307,A:A)",asdetermined
below.

Theformulaworkseveniftherangecontainsblanks,errorvalues(like#N/A),andtextvalues.

9.99999999999999E+307[FormulaBreak]

ThisistheLargest+ivenumberinExcel.

=MATCH(9.99999999999999E+307,A:A)[FormulaBreak]

Returnsrownumberofthelastnumericvalue,withincolumn,whichis10.(ReferTable4).Therangedoesn'thavetobeafullcolumn.YoucanuseA5:A50
insteadofA:A.

MATCHseeminglylooksforanumericvalueatthebottomofthecolumn,presumingtherangeisinascendingorder,andignorestext&nonnumericvalues.
MATCHlooksfor9.99999999999999E+307inthecolumn,andintheabsenceofMatch_type0(tofindanexactmatch),itlooksforthelargestvaluethatis
less than or equal to 9.99999999999999E+307. It then determines that the last numeric in the column is the largest value that is less than or equal to
9.99999999999999E+307.

MATCHreturnstherelativepositionintheLookUpArray,ofthelastnumericvalue(viz.numericvalueatthebottomofthecolumn)whichwillobviouslybe
smallerthanorequaltothislargest.

Iftherangehasnonumericvalue,theMATCHformulawillreturnthe#N/Aerror.

Table5

Formulafor'Lastnumericvalueincolumn'

=LOOKUP(9.99999999999999E+307,A:A)[Formula]

Theformulareturnslastnumericvalueincolumn,whichis22.(ReferTable5).

IftheLook_UpvalueisgreaterthanthelargestvalueintheLook_UpArray,itwillreturnthelastnumberinthearray,eveniftheLook_UpArrayisnotsorted
inascendingorder,whichisrequiredfortheLOOKUPformula.

LOOKUPseeminglystartsfromthebottomoftheLookUpArrayandsearchesverticallyup,presumingtherangeisinascendingorderandthelastnumber
beingthelargestintheLookUpArray.

Hence9.99999999999999E+307hasbeenarbitrarilychosenastheLookUpvalue,whichyouknowwillbegreaterthanthevalueyouarelookingfor.

Theformulaworkseveniftherangecontainsblanks,errorvalues(like#N/A),andtextvalues.

Wherethevaluetobefoundislargerthananyvalueofthatparticulartype(viz.numericortext)inthereferencedvalue,theLOOKUPfunctionseemingly
returnsthelastlisteditemofthatparticulartype.

9.99999999999999E+307[FormulaBreak]

ThisistheLargest+ivenumberinExcel.

Table6

Formulafor'Lasttextvalueincolumn'

=INDEX(A:A,MATCH(REPT("z",255),A:A))[Formula]
{PresumingnoGreek,Cyrillic,Hebrew,orArabiccharactersintextvalues}

The formula returns last text value in column, which is "Humpty". (Refer Table 6). INDEX Returns the text value in the array selected by the row number
index.Rownumberis"=MATCH(REPT("z",255),A:A)",asdeterminedbelow.

=REPT("z",255)[FormulaBreak]

InExcelthisevaluatestothelargeststringvalue,consistingof255Zcharacters(zzzzzzz.....),tofindthelasttextentry.

Greek,Cyrillic,Hebrew,orArabiccharacterscomeafter"z"inthesortorder.Hencetheexclusion.

Theformulaworkseveniftherangecontainsblanks,errorvalues(like#N/A),andnumericalvalues.

=MATCH(REPT("z",255),A:A)[FormulaBreak]

Returns row number of the last text value, within column, which is 9. (Refer Table 6). The range doesn't have to be a full column. You can use A5:A50
insteadofA:A.

MATCHseeminglylooksforatextvalueatthebottomofthecolumn,presumingtherangeisinascendingorder,andignoresnumerics&nontextvalues.
MATCHlooksforthestringof255z'sinthecolumn,andintheabsenceofMatch_type0(tofindanexactmatch),itlooksforthelargestvaluethatisless
thanorequalto255z's.Itthendeterminesthatthelaststringinthecolumnisthelargestvaluethatislessthanorequalto255z's.

MATCHreturnstherelativepositionintheLookUpArray,ofthelasttextvalue(viz.textvalueatthebottomofthecolumn)whichwillobviouslybesmaller
thanorequaltothislargest.

Iftherangehasnotextvalue,theMATCHformulawillreturnthe#N/Aerror.

Table7

Formulafor'Lasttextvalueincolumn'

=LOOKUP(REPT("z",255),A:A)[Formula]
{PresumingnoGreek,Cyrillic,Hebrew,orArabiccharactersintextvalues}

Theformulareturnslasttextvalueincolumn,whichis"Humpty".(ReferTable7).Therangedoesn'thavetobeafullcolumn.YoucanuseA5:A50instead
ofA:A.

LOOKUP seemingly starts from the bottom of the LookUp Array and searches vertically up, presuming the range is in ascending order and the last text
valuebeingthelargestintheLookUpArray.

LOOKUPlooksforandreturnsatextvalue,andignoresnumerics&nontextvalues.

Theformulaworkseveniftherangecontainsblanks,errorvalues(like#N/A),andnumericalvalues.

Wherethevaluetobefoundislargerthananyvalueofthatparticulartype(viz.numericortext)inthereferencedvalue,theLOOKUPfunctionseemingly
returnsthelastlisteditemofthatparticulartype.

=REPT("z",255)[FormulaBreak]

InExcelthisevaluatestothelargeststringvalue,consistingof255Zcharacters(zzzzzz.....),tofindthelasttextentry.

Greek,Cyrillic,Hebrew,orArabiccharacterscomeafter"z"inthesortorder.Hencetheexclusion.

Table8

Formulafor'Lastvalueincolumn,numericortext'

{=INDIRECT("A"&MAX(IF(NOT(ISBLANK(A:A)),ROW(A:A))))}[Formula]

Theformulareturnslastvalueincolumn,numericortext,whichis22.(ReferTable8).ReturnsvalueofhighestrownumberincolumnA,usingINDIRECT
functionforcellreference.

Enter as an array formula: type the formula in the cell and then press CTRL+SHIFT+ENTER instead of just ENTER. Excel will automatically display the
formulaenclosedinbraces{}.

=IF(NOT(ISBLANK(A:A)),ROW(A:A))[FormulaBreak]

ReturnsFALSEifcellincolumnAisblank,elsereturnsrownumberifNOTBLANK.

{=MAX(IF(NOT(ISBLANK(A:A)),ROW(A:A)))}[FormulaBreak]

Returnsthehighest/largestrownumberviz.rownumberofthelastnonblankcellincolumnA,whichis10.(ReferTable8)

Enterasanarrayformula.

Table9

Formulafor'Lastvalueincolumn,numericortext'

=INDIRECT("A"&SUMPRODUCT(MAX((ROW(A:A))*(A:A<>""))))[Formula]

Theformulareturnslastvalueincolumn,numericortext,whichis22.(ReferTable9).ReturnsvalueofhighestrownumberincolumnA,usingINDIRECT
functionforcellreference.

Formulawillnotworkifcellshaveerrorvalueslike#REF!,#N/A,#DIV/0!,.

=(ROW(A:A))*(A:A<>"")[FormulaBreak]

Thispartoftheformulamultipliesrownumber,with1incasecellincolumnAisnonblankandwith0(zero)ifcellisblank.

ReturnsrownumberincasecellincolumnAisnonblankand0(zero)ifcellisblank.

=MAX((ROW(A:A))*(A:A<>""))[FormulaBreak]

ThispartoftheformulareturnslargestrownumberofnonblankcellincolumnA,ifenteredasanarrayformulaviz.{=MAX((ROW(A:A))*(A:A<>""))}.Ifnot
anarrayformula,thenformula=SUMPRODUCT(MAX((ROW(A:A))*(A:A<>"")))willreturnthelargestrownumberofnonblankcellincolumnA.

=SUMPRODUCT(MAX((ROW(A:A))*(A:A<>"")))[FormulaBreak]

Returnsthehighest/largestrownumberviz.rownumberofthelastnonblankcellincolumnA,whichis10(ReferTable9).

Table10

Formulafor'Lastvalueincolumn,numericortext'

=LOOKUP(2,1/(LEN(A:A)>0),A:A)[Formula]

Theformulareturnslastvalueincolumn,numericortext,whichis22.(ReferTable10)

TheLOOKUPfunctionsearchesfortheLookup_value"2"intheLookup_vectorwhichonlyhasvaluesofeither1or#DIV/0!.Notfindingthis,itwillmatch
thelastvaluethatislessthanorequaltotheLookup_value,whichisthelast"1",andreturnthecorrespondingvalue/entryincolumnA(Result_vector).

=LOOKUP(2,1/(LEN(A:A)>0),A:A)[FormulaBreak]

TheformulausesLOOKUPfunctioninVECTORform.ThefirstparameterisLookup_value,thesecondparameterisLookup_vectorandthethirdparameter
isResult_vector.

1/(LEN(A:A)>0)[FormulaBreak]

Second parameter of Lookup_vector > in this formulation, the formula returns an array of values 1 or #DIV/0! viz. {1,1,#DIV/0!,1,#DIV/0!,..}, value 1
indicatinganonblankcelland#DIV/0!indicatingablankcell.AnonblankcellreturnsTRUEwiththefunctionLEN(A:A)>0and1/TRUEreturnsthevalue1,
whileablankcellreturnsFALSEwiththefunctionLEN(A:A)>0and1/FALSEreturnsthevalue#DIV/0!.

Table11

Formulafor'LastRownumber,numericortextvalue'

=LOOKUP(2,1/(LEN(A:A)>0),ROW(INDIRECT("1:65536")))[Formula]

Theformulareturnslastrownumber,numericortextvalue,whichis10.(ReferTable11)

TheLOOKUPfunctionsearchesfortheLookup_value"2"intheLookup_vectorwhichonlyhasvaluesofeither1or#DIV/0!.Notfindingthis,itwillmatch
thelastvaluethatislessthanorequaltotheLookup_value,whichisthelast"1",andreturnthecorrespondingrownumber(Result_vector).

"65536"inIndirectFunction,indicatesmaximumnumberofrowsinExcel2003.Formulavalidforpre2007Excelversions.

=LOOKUP(2,1/(LEN(A:A)>0),A:A)[FormulaBreak]

TheformulausesLOOKUPfunctioninVECTORform.ThefirstparameterisLookup_value,thesecondparameterisLookup_vectorandthethirdparameter
isResult_vector.

1/(LEN(A:A)>0)[FormulaBreak]

Second parameter of Lookup_vector > in this formulation, the formula returns an array of values 1 or #DIV/0! viz. {1,1,#DIV/0!,1,#DIV/0!,..}, value 1
indicatinganonblankcelland#DIV/0!indicatingablankcell.AnonblankcellreturnsTRUEwiththefunctionLEN(A:A)>0and1/TRUEreturnsthevalue1,
whileablankcellreturnsFALSEwiththefunctionLEN(A:A)>0and1/FALSEreturnsthevalue#DIV/0!.

ROW(INDIRECT("1:65536"))[FormulaBreak]

Inthisformulation,theformulageneratesanarrayofconsecutiveintegers,ofrownumbers.

Table12

Formulafor'LastRownumber,numericortextvalue'

=SUMPRODUCT(MAX((ROW(A:A))*(A:A<>"")))[Formula]

Theformulareturnslastrownumber,numericortextvalue,whichis10.(ReferTable12).Returnsthehighest/largestrownumberviz.rownumberofthelast
nonblankcellincolumnA.

Formulawillnotworkifcellshaveerrorvalueslike#REF!,#N/A,#DIV/0!,.

=(ROW(A:A))*(A:A<>"")[FormulaBreak]

Thispartoftheformulamultipliesrownumber,with1incasecellincolumnAisnonblankandwith0(zero)ifcellisblank.

ReturnsrownumberincasecellincolumnAisnonblankand0(zero)ifcellisblank.

=MAX((ROW(A:A))*(A:A<>""))[FormulaBreak]

ReturnslargestrownumberofnonblankcellincolumnA,ifenteredasanarrayformulaviz.{=MAX((ROW(A:A))*(A:A<>""))}.Ifnotanarrayformula,then
formula=SUMPRODUCT(MAX((ROW(A:A))*(A:A<>"")))willreturnthelargestrownumberofnonblankcellincolumnA.

Table13

Formulafor'LastRownumber,numericortextvalue'

{=MAX(ROW(A:A)*(A:A<>""))}[Formula]

Theformulareturnslastrownumber,numericortextvalue,whichis10.(ReferTable13).Returnsthehighest/largestrownumberviz.rownumberofthelast
nonblankcellincolumnA.

Formulawillnotworkifcellshaveerrorvalueslike#REF!,#N/A,#DIV/0!,.

Enterasanarrayformula.Toenteraformulaasanarrayformula,typetheformulainthecellandthenpressCTRL+SHIFT+ENTERinsteadofjustENTER.
Excelwillautomaticallydisplaytheformulaenclosedinbraces{}.

=(ROW(A:A))*(A:A<>"")[FormulaBreak]

Thispartoftheformulamultipliesrownumber,with1incasecellincolumnAisnonblankandwith0(zero)ifcellisblank.

ReturnsrownumberincasecellincolumnAisnonblankand0(zero)ifcellisblank.

Next

(/excel/index.php?option=com_content&view=article&id=79:leftlookupwithvlookup&catid=77&Itemid=473)

Home(/excel/index.php?option=com_content&view=article&id=182&Itemid=435)
ExcelTips(/excel/index.php?option=com_content&view=category&id=77&Itemid=473)

Contact(/excel/index.php?option=com_contact&view=contact&id=10&Itemid=493)
AboutUs(/excel/index.php?option=com_content&view=article&id=183&Itemid=491)
Testimonials(/excel/index.php?option=com_content&view=article&id=184&Itemid=492)
WebsiteUsePolicy(/excel/index.php?option=com_content&view=article&id=359&Itemid=609)
2016Globaliconnect.com(http://www.globaliconnect.com/excel_new/)AllRightReserved.

BacktoTop

Вам также может понравиться