MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 06:41 PM   #1
ADRIAN2
 
Join Date: Mar 2004
Posts: 1
Default Return the last number typed in a column

Dear Folks;

I have a column of numbers, I wish to have the last number entered always shown in a seperate table. How do I accomplish this with excel formulas.

Best Regards

Adrian D.
ADRIAN2 is offline   Reply With Quote
Old Mar 30th, 2004, 06:50 PM   #2
DRJ
MrExcel MVP
 
DRJ's Avatar
 
Join Date: Feb 2002
Location: California
Posts: 3,857
Default

Hi - Welcome to the board

If the column is A then

=INDEX(A:A,MATCH(9.99999999999999E+307,A:A),1)
__________________
Excel VBA Training and Certification (Lesson 1 is free)
<hr>

<hr>-Jacob
DRJ is offline   Reply With Quote
Old Mar 30th, 2004, 06:51 PM   #3
Damon Ostrander
MrExcel MVP
 
Damon Ostrander's Avatar
 
Join Date: Feb 2002
Location: Denver, Colorado USA
Posts: 3,876
Default Re: Return the last number typed in a column

Hi Adrian,

I'm not aware of a built-in worksheet function that does this. So here is a user-defined function (UDF) that adds this capability to Excel:

Function LastVal(InRange As Range) As Variant
'returns the last value in the first column of InRange
With InRange.Columns(1)
If IsEmpty(.Cells(.Cells.Count)) Then
LastVal = .Cells(.Cells.Count).End(xlUp).Value
Else
LastVal = .Cells(.Cells.Count).Value
End If
End With
End Function

To use this you would do something like:

=LastVal(B:B)

to return the last value in column B, or

=LastVal(B5:B200)

to return the last non-empty cell in B5:B200.

To install this UDF simply go to the Visual Basic Editor (keyboard Alt-TMV), insert a new macro module (Alt-IM), and paste the above code into the Code Pane. It will be immediately available for use from any worksheet in your workbook.
__________________
Keep Excelling.

Damon

VBAexpert Excel Consulting
(My other lives: http://members.tripod.com/playitagaindamon ,
http://community.webshots.com/user/piadamon )
Damon Ostrander is offline   Reply With Quote
Old Mar 30th, 2004, 06:51 PM   #4
Brian from Maui
 
Brian from Maui's Avatar
 
Join Date: Feb 2002
Posts: 7,605
Default Re: Return the last number typed in a column

Quote:
Originally Posted by ADRIAN2
Dear Folks;

I have a column of numbers, I wish to have the last number entered always shown in a seperate table. How do I accomplish this with excel formulas.

Best Regards

Adrian D.
=INDEX(A:A,MATCH(9.99999999999999E+307,A:A))

=LOOKUP(9.99999999999999E+307,Sheet1!A:A)

caveat, will return #N/A if no values are in the column and will return only numerica vales

=INDEX(Sheet1!G:G,MATCH(REPT("z",255),Sheet1!G:G))

=LOOKUP(REPT("z",255),Sheet1!G:G)

will return text

Edit,

Geez, I'm slow. As an alternative using Morefunc addin, this returns either text or numeric

=LASTROW(A:A)
Brian from Maui is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 08:37 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.