VBA代码隐藏行n最大 [英] VBA code to hide rows n-maximum

查看:131
本文介绍了VBA代码隐藏行n最大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel 2010 VBA中是否有任何代码可以将行n(例如第200行)隐藏到最大行?

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表格的名称特别是 main

Btw the name of the sheet in particular is main.

推荐答案

:要清楚,我将这个问题解释为从行200隐藏到使用的行与数据(如果最后使用的行超过200)

这样的东西

代码

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

在特定工作表上工作

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

这篇关于VBA代码隐藏行n最大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆