View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Neal Zimm Neal Zimm is offline
external usenet poster
 
Posts: 345
Default Hidden Property 1004 Error, Union of Rows

K - Well, I am embarrassed, .entirerow worked, when u mentioned it the

first time I could not believe that when union'ing rows, that you would
need this property, after all, entire rows are being union'd.

There's still the question of why the (fromrow & ":" & torow) worked. It
must be that in this case the rows are contiguous.

My guess is that Msoft does not consider a union of rows to be rows, but
rather a bunch of cells, hence .entirerow is needed.

Thanks again,
Neal



--
Neal Z


"keiji kounoike" <"kounoike AT mbh.nifty." wrote:

Hi Neal

One more thing.
As i said in my previous post, if you want to hide rows obtained by
using union, you need to use entirerow property to hide rows.
So,
Set OneRng = Rows("21:22")
Set TwoRng = Rows("20:20")
Set RowsRng = Application.Union(OneRng, TwoRng)
RowsRng.EntireRow.Hidden=true

would hide the unioned rows

Keiji

Neal Zimm wrote:
Hi Keiji

I put the workaround code first in the Sub below to show you what works.
It's followed by the extract from my App Function which does not work.

I've run the code and still get the 1004 error.
My ranges are NOT cell ranges but row ranges, so I don't think
cellrng.entirerow is applicable.

I'm still at a loss. What do you think? I'm running excel 2002.
The worksheet is not protected.

Sub Union_Hidden_Test()
Dim DebugRng As Range
Dim RowsRng As Range
Dim OneRng As Range
Dim TwoRng As Range
Dim FromRow As Long, ToRow As Long

Rows("18:23").Hidden = False 'set up test

'equivalent Workaround code

FromRow = 20: ToRow = 22

Set DebugRng = Rows(FromRow & ":" & ToRow)

MsgBox DebugRng.Address 'got $20:$22 as expected

DebugRng.Hidden = True 'rows hide correctly

If DebugRng.Hidden Then MsgBox "hidden" Else MsgBox "not hidden"
' above displayed hidden


Rows("18:23").Hidden = False 'set up next test

Rows("21:22").Hidden = True
Rows("20:20").Hidden = True

Set OneRng = Rows("21:22")
Set TwoRng = Rows("20:20")

Set RowsRng = Application.Union(OneRng, TwoRng)

MsgBox RowsRng.Address 'got $20:$22 as expected

'line below gets 1004 error, unable to get the hidden property of the range
' class 'Can you explain why ?

If RowsRng.Hidden Then MsgBox "hidden" Else MsgBox "not hidden"
End Sub