简体   繁体   中英

Excel VBA showing specific rows

I am creating a holidayplanner for my Department. We are about 150 People in 9 Groups. I want to create a button which filters the members of each Group.

At the Moment I use this code:

Sub IFK02einblenden()

    Application.ScreenUpdating = False

    ActiveSheet.Rows(8).Hidden = True
    ActiveSheet.Rows(9).Hidden = False
    ActiveSheet.Rows(10).Hidden = True
    ActiveSheet.Rows(11).Hidden = True
    ActiveSheet.Rows(12).Hidden = False
    ActiveSheet.Rows(13).Hidden = False
    ActiveSheet.Rows(14).Hidden = False
    ActiveSheet.Rows(15).Hidden = True
    ActiveSheet.Rows(16).Hidden = True
    //and so on and so on till row 158

    Application.ScreenUpdating = True

End Sub

With 9 modules like this the performance of the macros is very poor.

Do you have an idea to optimize this with range attributes or something else?

At click on the button "Group ONE" The members of Group ONE should be shown like "show me row 8 AND row 12-38"

If you don't want to use filter and any other alternative then please try something like this

    Sub GroupOne()
    ActiveSheet.Rows("8:8").EntireRow.Hidden = False
    ActiveSheet.Rows("12:38").EntireRow.Hidden = False
    End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM