View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Kevin H. Stecyk Kevin H. Stecyk is offline
external usenet poster
 
Posts: 12
Default Set Visible Cells To TRUE

Bob Phillips wrote...
Is KeyRange an Excel defined name. If so, it works fine for me, except
that nothing get sets to FALSE.


Hi Bob,

Yes, "KeyRange" is an XL spreadsheet local defined name belonging to Sheet1.

Let's assume that KeyRange is A100:A200.

Let's further assume that all cells are visible.

Sub SetRange()

'\ Step 1
Worksheets("Sheet1").Range("KeyRange").Formula = False

'\ Step 2
Worksheets("Sheet1").Range("KeyRange").SpecialCell s(xlCellTypeVisible).Formula
= True

End Sub

Using our prior assumptions, we find that all cells are set to FALSE under
step 1, and then all cells are set to TRUE under step 2.

So far, so good.

Next, Let's have another column B100:B200 (let's call this range
"FilterRange") where it is filled with random integers between 1 and 3.

Let's set all cells to TRUE in A100:A200 (KeyRange).

Let's filter the rows that only those rows that equal 1 in FilterRange are
visible.

Running the program again, we find that a) under step 1, only visible cells
are set to false, not the hidden cells; and b) visible cells are set to
true, which is correct.

Thus, the program fails to achieve my objective. That is, under step 1, all
cells should be set to FALSE, regardless if they are visible or not. And
then step 2 should reset the visible cells to TRUE.

Any ideas how to fix step 1 so that all cells are set to FALSE?

Regards,
Kevin