Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Run-time error 1004 while conditionally hiding rows as a result ofworksheet protection

Hello,

I have used the code below, which is tied to a multi-drop-down-list in
order to unhide/hide rows (unhiding rows = yes = 1, hiding rows = no =
2.

The macro works fine, unless the worksheet is being protected. I then
get a runtime-error 1004, saying the hidden property of the range
object cannot be determined (Code-Line 8). Is there any work-around
about this available? Many many thanks!


Sub HideRows()

Dim Rng As Range

Set Rng = Sheets("Ziel1").Range("K6")

If Rng.Value = 1 Then

Rows("7:19").EntireRow.Hidden = False

Range("K6").Select

ElseIf Rng.Value = 2 Then

Rows("7:19").EntireRow.Hidden = True

End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Run-time error 1004 while conditionally hiding rows as a result of

When you protect the sheet, you need to have the option of "Format rows"
enabled, or you can't hide/unhide rows.

VBA for this is:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingRows:=True
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"ran58" wrote:

Hello,

I have used the code below, which is tied to a multi-drop-down-list in
order to unhide/hide rows (unhiding rows = yes = 1, hiding rows = no =
2.

The macro works fine, unless the worksheet is being protected. I then
get a runtime-error 1004, saying the hidden property of the range
object cannot be determined (Code-Line 8). Is there any work-around
about this available? Many many thanks!


Sub HideRows()

Dim Rng As Range

Set Rng = Sheets("Ziel1").Range("K6")

If Rng.Value = 1 Then

Rows("7:19").EntireRow.Hidden = False

Range("K6").Select

ElseIf Rng.Value = 2 Then

Rows("7:19").EntireRow.Hidden = True

End If

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Run-time error 1004 while conditionally hiding rows as a resultof

On 21 Jul., 19:10, Luke M wrote:
When you protect the sheet, you need to have the option of "Format rows"
enabled, or you can't hide/unhide rows.

VBA for this is:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingRows:=True
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*

"ran58" wrote:
Hello,


I have used the code below, which is tied to a multi-drop-down-list in
order to unhide/hide rows (unhiding rows = yes = 1, hiding rows = no =
2.


The macro works fine, unless the worksheet is being protected. I then
get a runtime-error 1004, saying the hidden property of the range
object cannot be determined (Code-Line 8). Is there any work-around
about this available? Many many thanks!


Sub HideRows()


Dim Rng As Range


Set Rng = Sheets("Ziel1").Range("K6")


If Rng.Value = 1 Then


Rows("7:19").EntireRow.Hidden = False


Range("K6").Select


ElseIf Rng.Value = 2 Then


Rows("7:19").EntireRow.Hidden = True


End If


End Sub


Hi Luke, many thanks for your help. Where do I place this code further
to the code that I wrote down? Sorry, but I am not a VBA-Crack at
all.... Thanks in advance!
Reply
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
conditionally hiding rows Derrick Excel Discussion (Misc queries) 13 June 20th 09 05:58 PM
1004 Error when hiding/unhiding rows ianb Excel Discussion (Misc queries) 5 March 27th 08 08:42 AM
Conditionally Hiding Rows Llobid Excel Discussion (Misc queries) 5 April 11th 06 10:56 PM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Hiding Rows Conditionally Mike Hogan Excel Discussion (Misc queries) 2 December 9th 04 10:05 PM


All times are GMT +1. The time now is 03:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"