Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 187
Default find cell address of last active cell in range

I'm trying to come up with a UDF, which I call endaddress() that will
return the cell address of the last active (used) cell in a range.

Example: assume cells A2:A5 have text/numbers in them. I want to be
able to enter in another cell =endaddress(A3) and have $A$5 be
returned.

This is what I've managed to come up with (from feedback given to me
in an earlier posting on this topic):

Function EndAddress(r As Range) As String
EndAddress = ""
For Each rr In r
If IsEmpty(rr) Then
Else
EndAddress = rr.Address
End If
Next
End Function

However, this merely returns the cell address I specify in the
function. If I enter =endaddress(A3) then $A$3 is returned, even if
that's not the last active cell in the range.

Any suggestions on how to modify this?

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default find cell address of last active cell in range

The function only analyzes the cells in the range that is passed to it.

Try =EndAddress(A:A)






"Dave F" wrote:

I'm trying to come up with a UDF, which I call endaddress() that will
return the cell address of the last active (used) cell in a range.

Example: assume cells A2:A5 have text/numbers in them. I want to be
able to enter in another cell =endaddress(A3) and have $A$5 be
returned.

This is what I've managed to come up with (from feedback given to me
in an earlier posting on this topic):

Function EndAddress(r As Range) As String
EndAddress = ""
For Each rr In r
If IsEmpty(rr) Then
Else
EndAddress = rr.Address
End If
Next
End Function

However, this merely returns the cell address I specify in the
function. If I enter =endaddress(A3) then $A$3 is returned, even if
that's not the last active cell in the range.

Any suggestions on how to modify this?

Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default find cell address of last active cell in range

Dave,
This gives $A$5 as requested.
But what would you want if a1:c3 were
X X b ' (b is blank/null)
X b b
b b b
and you called EndAddress(Range("A1"))
Would you want $A$2 or $B$1 or something else?

Function EndAddressCol(r As Range) As String
EndAddressCol = r.End(xlDown).Address
End Function ' Dave C D-C

Dave F wrote:
I'm trying to come up with a UDF, which I call endaddress() that will
return the cell address of the last active (used) cell in a range.

Example: assume cells A2:A5 have text/numbers in them. I want to be
able to enter in another cell =endaddress(A3) and have $A$5 be
returned.

This is what I've managed to come up with (from feedback given to me
in an earlier posting on this topic):

Function EndAddress(r As Range) As String
EndAddress = ""
For Each rr In r
If IsEmpty(rr) Then
Else
EndAddress = rr.Address
End If
Next
End Function

However, this merely returns the cell address I specify in the
function. If I enter =endaddress(A3) then $A$3 is returned, even if
that's not the last active cell in the range.

Any suggestions on how to modify this?

Thanks.



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Reply
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
find last cell in range with data, display cell address sevi61 Excel Worksheet Functions 14 October 29th 07 08:36 PM
How to find the address of the min cell within a range Will Excel Worksheet Functions 2 May 17th 07 08:45 PM
Find cell address of previous active cell Google Excel Excel Programming 1 November 21st 06 12:14 AM
Find address of active cell Dave Excel Worksheet Functions 5 September 6th 06 06:43 PM
find range name for active cell Len Excel Programming 2 November 22nd 05 02:37 PM


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

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

About Us

"It's about Microsoft Excel"