LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
sandr5
 
Posts: n/a
Default Function to select second-to-last non-empty cell


I'm in need of a function that will select the second-to-last used sell
in a specified row or column.

I have a function that selects the LAST cell...(I've included the code
below)but now I need another function that selects the SECOND-TO-LAST
cell can some code be inserted into this to make that happen?....thanks
in advance.




Function Last_Cell_value(Col_or_Row_Range As Range)
'
' Last_Cell_value Macro
' Returns the value in the last occupied cell of a _
single column or row range. *Range cannot include _
row 65536 or column IV.*
'
'
' =Last_Cell_value($A$5:$Z$5) for ROW
' =Last_Cell_value($A$1:$A$500) for COLUMN
'
'
'
If Col_or_Row_Range.Columns.Count = 1 Then
If Col_or_Row_Range.Cells _
(Col_or_Row_Range.Rows.Count, 1) < "" Then
Last_Cell_value = _
Col_or_Row_Range.Cells(Col_or_Row_Range.Rows.Count , 1)
Else
Last_Cell_value = _
Col_or_Row_Range.Cells _
(Col_or_Row_Range.Rows.Count + 1, 1).End(xlUp)
End If

Else

If Col_or_Row_Range.Cells _
(1, Col_or_Row_Range.Columns.Count) < "" Then
Last_Cell_value = _
Col_or_Row_Range.Cells(1, Col_or_Row_Range.Columns.Count)
Else
Last_Cell_value = _
Col_or_Row_Range.Cells _
(1, Col_or_Row_Range.Columns.Count).End(xlToLeft)
End If

End If
End Function


--
sandr5
------------------------------------------------------------------------
sandr5's Profile: http://www.excelforum.com/member.php...o&userid=32675
View this thread: http://www.excelforum.com/showthread...hreadid=524803

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function that Returns address of that cell? RayWolfDog Excel Worksheet Functions 2 February 15th 06 04:54 PM
I NEED HELP with the SPELLNUMBER Function vag Excel Worksheet Functions 0 June 21st 05 08:17 AM
Possible Lookup Table Karen Excel Worksheet Functions 5 June 8th 05 09:43 PM
Hyperlinks using R[1]C[1] and offset function in its cell referenc Elijah-Dadda Excel Worksheet Functions 0 March 5th 05 03:31 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 04:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"