Share via

Rows Hide/Unhide Not Working

Anonymous
2014-03-15T16:15:36+00:00

I am trying to simply hide and unhide rows on command; however, the macro I setup is not working, I keep getting a type mismatch error. Can someone please help me fix this issue and just make the whole thing work:

Sub August2013()

If Rows("17:49").Hidden = True And Rows("57:123").Hidden = True Then

Rows("17:49.57:123").Hidden = True

Rows("16,50:56").Hidden = False

ElseIf Rows("17:49").Hidden = False And Rows("57:123").Hidden = False Then

Rows("17:49").Hidden = False

Rows("16,19,22,25,28,31,34,37,40,43,46,49,50:56").Hidden = True

End If

End Sub

Thank you in advance!

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2014-03-15T16:46:49+00:00

I'm not sure it will do what you want, but here is a version that does not cause an error message:

Sub August2013()

    If Range("17:49").EntireRow.Hidden = True And _

            Range("57:123").EntireRow.Hidden = True Then

        Range("17:49.57:123").EntireRow.Hidden = True

        Range("16:16,50:56").EntireRow.Hidden = False

    ElseIf Range("17:49").EntireRow.Hidden = False And _

            Range("57:123").EntireRow.Hidden = False Then

        Range("17:49").EntireRow.Hidden = False

        Range("16:16,19:19,22:22,25:25,28:28,31:31,34:34," & _

            "37:37,40:40,43:43,46:46,49:56").EntireRow.Hidden = True

    End If

End Sub

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2014-03-15T18:52:06+00:00

    Hey Hans, Its nice to hear from you again. Thank you for your response, as always, worked great!

    Was this answer helpful?

    0 comments No comments