Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default Runtime Error in code

Hi
Here's my code and it work initially, but now I get the following error
message:
"Runtime error 1004: Unable to set the hidden property of the range class."
Can anyone help as to why?

Private Sub HideEmptyCases_Click()
If Range("Z5") = "" Then Columns("Z:AB").Hidden = True
If Range("W5") = "" Then Columns("W:Y").Hidden = True
If Range("T5") = "" Then Columns("T:V").Hidden = True
If Range("Q5") = "" Then Columns("Q:S").Hidden = True
If Range("N5") = "" Then Columns("N:P").Hidden = True
If Range("K5") = "" Then Columns("K:M").Hidden = True
If Range("H5") = "" Then Columns("H:J").Hidden = True
If Range("E5") = "" Then Columns("E:G").Hidden = True
If Range("B5") = "" Then Columns("B:D").Hidden = True

End Sub

Thanks
Lisa
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Runtime Error in code

Try unprotecting the sheet

Activesheet.Unprotect


"Lisa" wrote in message
...
Hi
Here's my code and it work initially, but now I get the following error
message:
"Runtime error 1004: Unable to set the hidden property of the range
class."
Can anyone help as to why?

Private Sub HideEmptyCases_Click()
If Range("Z5") = "" Then Columns("Z:AB").Hidden = True
If Range("W5") = "" Then Columns("W:Y").Hidden = True
If Range("T5") = "" Then Columns("T:V").Hidden = True
If Range("Q5") = "" Then Columns("Q:S").Hidden = True
If Range("N5") = "" Then Columns("N:P").Hidden = True
If Range("K5") = "" Then Columns("K:M").Hidden = True
If Range("H5") = "" Then Columns("H:J").Hidden = True
If Range("E5") = "" Then Columns("E:G").Hidden = True
If Range("B5") = "" Then Columns("B:D").Hidden = True

End Sub

Thanks
Lisa



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default Runtime Error in code

Thanks Joe, that worked great!

Cheers
Lisa

"Joe" wrote:

Try unprotecting the sheet

Activesheet.Unprotect


"Lisa" wrote in message
...
Hi
Here's my code and it work initially, but now I get the following error
message:
"Runtime error 1004: Unable to set the hidden property of the range
class."
Can anyone help as to why?

Private Sub HideEmptyCases_Click()
If Range("Z5") = "" Then Columns("Z:AB").Hidden = True
If Range("W5") = "" Then Columns("W:Y").Hidden = True
If Range("T5") = "" Then Columns("T:V").Hidden = True
If Range("Q5") = "" Then Columns("Q:S").Hidden = True
If Range("N5") = "" Then Columns("N:P").Hidden = True
If Range("K5") = "" Then Columns("K:M").Hidden = True
If Range("H5") = "" Then Columns("H:J").Hidden = True
If Range("E5") = "" Then Columns("E:G").Hidden = True
If Range("B5") = "" Then Columns("B:D").Hidden = True

End Sub

Thanks
Lisa




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
runtime error code 1004 Karen Excel Worksheet Functions 1 May 13th 10 12:21 AM
VB Code + Runtime error 91 [email protected] Excel Programming 0 February 13th 07 10:49 PM
VBA Code runtime error only after opening Locals window keeena Excel Programming 3 February 22nd 06 06:30 PM
RunTime Error 424 in a USERFORM's code JimP Excel Programming 0 November 26th 04 05:27 AM
Repost with code - Runtime error '1004' muziq2[_20_] Excel Programming 5 July 17th 04 12:46 AM


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