View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
fedude fedude is offline
external usenet poster
 
Posts: 74
Default function to return a "sub-range"

Won't this return the entire sheet?

"Norman Jones" wrote:


Hi Ferdude,

Perhaps, trry something like:

Set myRng = Range("AP4").CurrentRegion


---
Regards.
Norman


"fedude" wrote in message
...
I have a range AP4:AQ63 that has data in the top few cells in the range.
The
remaining cells are empty (I use delete to clear them).

I need a routine to read this range and return a smaller range that only
has
non-blank cells in it. For example, if there are only 15 rows filled in
in
the range, the function would return AP4:AQ19.

I have a loop that goes through the range, I just need some help
constructing the range to return. Here is what I have so far (thanks to
snippets I've gotten from this forum):

Function GetSubRange() As Range

Dim r As Range
Set r = Worksheets("Subs").Range("AP4")

Do While Not r = ""
Set r = r.Offset(1, 0)
Loop

GetSubRange = ???

End Function