本文介绍了VBA代码可以在几个工作表中隐藏多个固定的离散行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是为了解决我写的一个宏的一部分,它会隐藏一些不同的表格(固定位置)行。我目前有:

I'm for a solution to part of a macro I'm writing that will hide certain (fixed position) rows across a few different sheets. I currently have:

Sheets(Sheet1).Range(5:20)。EntireRow.Hidden = True

隐藏Sheet1中的行5-20。我也想在Sheet2中隐藏(为争论起见),第6行,第21行和第35-38行 - 我可以通过重复上述代码行3次来做到这一点;但是我确定有一个更好的方法,就像一个学习练习一样。

To hide rows 5-20 in Sheet1. I also would like to hide (for arguements sake), row 6, row 21, and rows 35-38 in Sheet2 - I could do this by repeating the above line of code 3 more times; but am sure there's a better way of doing this, just as a learning exercise.

任何帮助非常感谢:)

Chris

推荐答案

指定一些范围的 Union

With Sheet1
    Union(.Range("1:5"), .Rows(7), .Range("A10"), .Cells(12, 1)).EntireRow.Hidden = True
End With

这篇关于VBA代码可以在几个工作表中隐藏多个固定的离散行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 06:07