LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Detect NULL (??) range?

My code detects an "X" in one column of a range; if present, that row is
hidden, and a new range is set to the intersection of that range and the
visible cells only of that range. Underneath is the formula
=COUNT((col7 rng1Work))
which counts the number of items in the intersection of the column range and
the visible cells range.

It all works fine - until I "X" out all five rows of the original range.
Then the COUNT doesn't change from whatever it was previously. I'm assuming
that since it hides all the rows, and there are no visible cells to
intersect with, the INTERSECT function fails, and my On Error Resume Next
flows right over it without burping - and without resetting my range.

How can I detect a NULL (?? correct term??) range, or the lack of a range,
when this occurs? (Note: the original range covers 5 rows, but this can
vary.)

Ed

' Hide rows with value of "X"
For i = 1 To rngThis.Rows.Count
If rngThis.Cells(i, 1).Value = "X" Or _
rngThis.Cells(i, 1).Value = "x" Then
rngThis.Rows(i).Hidden = True
End If
Next i

' Reset range to visible cells only
Range(strName).SpecialCells(xlVisible).Select
Set rngVis = Selection
Set rngThis = Application.Intersect(Range(strName), rngVis)
Range(strName).Rows.Hidden = False
rngThis.Name = strName & "Work"

Calculate


 
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
Sum a range that IS NOT NULL JKELSTONE Excel Worksheet Functions 6 April 30th 09 02:49 AM
Detect strings in a range Rich57 Excel Worksheet Functions 4 January 1st 08 12:00 AM
Detect non-blank range Connie Excel Discussion (Misc queries) 2 October 16th 06 08:36 PM
Detect if a selected cell is within a named range CraigB Excel Programming 2 November 25th 04 03:44 PM
How Do I Detect An Entry In A Range Of Cells Minitman[_4_] Excel Programming 6 October 6th 04 03:23 PM


All times are GMT +1. The time now is 02:09 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"