Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Find Used area of a range

I know that Excel allows you to create a range of the utilized area of a sheet. However, is there an easy way to find the utilized area of a range? For instance, if my area of interest is A5:B - essentially the first two columns, starting at the fifth row. There could be 1 entry in that space, or 50. (For all practical purposes, I doubt we'd ever come close to, say, 500, so the starting out range could be something like A5:B750)

But, given those bounds, is there an easy way for me to create a sub-range that is just the utilized area of that main range?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find Used area of a range

Dim rnga as Range, rngb as Range
Dim rng as Range
set rnga = Cells(rows.count,1).End(xlup)
set rngb = cells(rows.count,2).end(xlup)
if rnga.row rngb.row then
set rng = Range("A5",rnga).Resize(,2)
else
set rng = Range("A5",rngb)
end if
msgbox rng.Address

--
Regards,
Tom Ogilvy

"MDW" wrote in message
...
I know that Excel allows you to create a range of the utilized area of a

sheet. However, is there an easy way to find the utilized area of a range?
For instance, if my area of interest is A5:B - essentially the first two
columns, starting at the fifth row. There could be 1 entry in that space,
or 50. (For all practical purposes, I doubt we'd ever come close to, say,
500, so the starting out range could be something like A5:B750).

But, given those bounds, is there an easy way for me to create a sub-range

that is just the utilized area of that main range?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Find Used area of a range

Probably overkill, but:

Function SubRange(BigRange As Range) As Range
Set SubRange = AntiRange(BigRange.SpecialCells(xlCellTypeBlanks), _
BigRange)
End Function

Function AntiRange(rngInner As Range, rngOuter As Range) As Range
Dim c As Range
If Not Intersect(rngInner, rngOuter) Is Nothing Then
For Each c In rngOuter.Cells
If Intersect(rngInner, c) Is Nothing Then
If AntiRange Is Nothing Then
Set AntiRange = c
Else
Set AntiRange = Union(c, AntiRange)
End If
End If
Next
End If
End Function

--

Vasant




"MDW" wrote in message
...
I know that Excel allows you to create a range of the utilized area of a

sheet. However, is there an easy way to find the utilized area of a range?
For instance, if my area of interest is A5:B - essentially the first two
columns, starting at the fifth row. There could be 1 entry in that space,
or 50. (For all practical purposes, I doubt we'd ever come close to, say,
500, so the starting out range could be something like A5:B750).

But, given those bounds, is there an easy way for me to create a sub-range

that is just the utilized area of that main range?


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 data in worksheet area that constantly changes Foggy1 Excel Worksheet Functions 2 August 23rd 08 01:20 PM
can I find the area under a plotted curve? Middlesex Excel Worksheet Functions 3 January 19th 08 10:05 PM
Find print area enginguven Excel Discussion (Misc queries) 1 January 12th 06 01:54 AM
how to find the area under a graph chogga Excel Discussion (Misc queries) 2 September 14th 05 01:12 PM
Find Method ; search area CG Rosén Excel Programming 1 November 22nd 03 01:29 PM


All times are GMT +1. The time now is 09:24 AM.

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"