Runtime Error in code

L

Lisa

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

More Efficient code than this 14
color hidden columns 5
Hiding and unhiding columns 1
Select failed? 5
Cut & Paste with hidden columns 2
Hiding Cells 1
variable not set error? 4
Complie Error 3

Top