Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find data in worksheet area that constantly changes | Excel Worksheet Functions | |||
can I find the area under a plotted curve? | Excel Worksheet Functions | |||
Find print area | Excel Discussion (Misc queries) | |||
how to find the area under a graph | Excel Discussion (Misc queries) | |||
Find Method ; search area | Excel Programming |