![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Join Date: Mar 2004
Posts: 1
|
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. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: California
Posts: 3,857
|
Hi - Welcome to the board
If the column is A then =INDEX(A:A,MATCH(9.99999999999999E+307,A:A),1) |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, Colorado USA
Posts: 3,876
|
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 ) |
|
|
|
|
|
#4 | |
|
Join Date: Feb 2002
Posts: 7,605
|
Quote:
=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) |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|