LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Hidden Property 1004 Error, Union of Rows

Hi All,
Am getting the 1004 unable to .. hidden property run time error.
I think I've proved it resulted from a union of rows as
shown in the code below.

I'm gonna use the workaround after cleaning up the code
but the broader question is are there other suspect
properties concerning a range resulting from a union ?

It's a morale buster.

Would appreciate comments on best way to proceed.

Thanks,
Neal Z.



Function PPDtEndRng_GetF(WkTimeWs As Worksheet, _
optional bThisMacHides as Boolean = False, ..more args) as Range

' more code not shown

With WkTimeWs
' PPsRowsHideSM constant is "26:26"
Set RowsRng = .Rows(PPsRowsHideSM)

'more code

' Line below is the 'bad' one
Set RowsRng = Application.Union(.Rows(FromRow & Colon & ToRow), _
RowsRng)

End With

If bThisMacHides Then GoSub HideRows

'more code

Exit Function


HideRows: 'Events, protection, and hide.

Dim bSave As Boolean, DebugRng As Range

Application.EnableEvents = False

With WkTimeWs 'debug code
bSave = .ProtectContents
ToRow = 26
If Not .Rows(FromRow & Colon & ToRow).Hidden Then MsgBox "not hidden"
' Yes
Set DebugRng = .Rows(FromRow & Colon & ToRow) 'equivalent of RowsRng
End With

MsgBox RowsRng.Address & " " & DebugRng.Address 'both $24:$26 no 1004 error

On Error Resume Next
MsgBox DebugRng.Hidden 'False as expected
MsgBox Err, , "DebugRng.Hidden": Err = 0 'OK no error

On Error Resume Next

If RowsRng.Hidden Then '1004 Unable.. prior to putting in On Error
'QED: Can't trust the RowsRng result of the Union .Hidden ????
GoTo workaround
Else
If Not WkTimeWs.ProtectContents Then
RowsRng.Hidden = True
Else
Call UNprotectPW(WkTimeWs, PW)
RowsRng.Hidden = True
Call ProtectPW(WkTimeWs, PW)
End If
End If

workaround: ' NO problem here, worked fine.
If Not DebugRng.Hidden Then

If bSave Then Call UNprotectPW(WkTimeWs, PW)

DebugRng.Hidden = True
End If

If bSave Then Call ProtectPW(WkTimeWs, PW)
Application.EnableEvents = True
Return
--
Neal Z
 
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
Rows hidden by Autofilter vs hidden by changing the Hidden property LEO@KCC Excel Programming 4 September 11th 07 10:14 AM
Hiding Rows Error - "Runtime Error 1004 - Unable to set the hidden property of the range class" Punsterr Excel Programming 2 April 9th 07 05:32 PM
1004 - Unable to set the hidden property of the range class Tim Whitley Excel Programming 3 February 20th 06 09:50 PM
Run Time Error 1004 Unable to set hidden property Lester Lee Excel Programming 3 July 22nd 04 03:31 AM


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