0

可能重复:
VBA代码隐藏行n-maximum

我目前正在使用此代码在 Excel VBA 上隐藏从 200 到最大值的行,但它似乎不起作用。知道出了什么问题吗?

我已经在第 1-200 行有数据。

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
4

1 回答 1

-1

试试这个

xlsRange = xlsSheet.Range("A0", "B999") 'select your range, probably need a way to specify from row 200 to maximum, i'm too lazay to do this
xlsRange.EntireRow.Hidden = True

这些文章将帮助您在 VBA 中创建动态范围

http://social.msdn.microsoft.com/Forums/en-IE/isvvba/thread/ef1f8134-f6fc-4f1a-8405-418d4817b0c3

http://www.ozgrid.com/News/excel-dynamic-ranges-vba.htm

于 2012-10-27T14:17:28.013 回答