VBA code to hide rows n-maximum

前端 未结 2 1943
粉色の甜心
粉色の甜心 2021-01-29 15:25

Is there there any code in Excel 2010 VBA that I can use to hide row n (e.g. row 200) to the maximum row?

Btw the name of the sheet in particular is

相关标签:
2条回答
  • 2021-01-29 15:58

    Updated comment: To be clear I interpreted this question as hiding from row 200 to the used row with data (if that last used row exceeded 200)

    Something like this

    code

    Sub HideEm()
        Dim rng1 As Range
        Set rng1 = ActiveSheet.Cells.Find("*", [a1], xlValues, , , xlPrevious)
        If Not rng1 Is Nothing Then
            If rng1.Row > 200 Then Rows("200:" & rng1.Row).Hidden = True
        End If
    End Sub
    

    to work on a specific sheet

    Sub HideEm()
    Dim ws As Worksheet
    Dim rng1 As Range
    Set ws = Sheets("main")
    Set rng1 = ws.Cells.Find("*", ws.[a1], xlValues, , , xlPrevious)
    If Not rng1 Is Nothing Then
        If rng1.Row > 200 Then ws.Rows("200:" & rng1.Row).Hidden = True
    End If
    End Sub
    
    0 讨论(0)
  • 2021-01-29 16:16

    Normally I would tell you to try and downvote your question but hey I'm lazy this morning so I'll just give you the answer for which you haven't worked for.

    Rows(200, ActiveSheet.Rows.Count).Hidden = true

    0 讨论(0)
提交回复
热议问题