vba 如果单元格等于 0,Vb 宏 excel 2007 隐藏行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19045934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Vb macro excel 2007 hide rows if cell equal zero
提问by Petty Bathish Jreish
I want to run a macro on a table which is part of a sheet , it goes from A18 to J33, the 18th row is the header. The macro should hide the rows that has zero in the J column cells.
我想在作为工作表一部分的表格上运行一个宏,它从 A18 到 J33,第 18 行是标题。宏应该隐藏 J 列单元格中为零的行。
Please help!!!!!!
请帮忙!!!!!!
回答by
When you see your spreadsheet hit ALT+F11. This will open VBE (visual basic editor) for you.
当您看到电子表格点击ALT+ 时F11。这将为您打开 VBE(可视化基本编辑器)。
right-click in the VBA Project Explorer
(if you can't see it then click View -> Project Explorer or CTRL+R
右键单击VBA Project Explorer
(如果您看不到它,则单击“查看”->“项目资源管理器”或CTRL+R
Insert a Module
插入模块
Copy and paste the below code
复制并粘贴以下代码
Sub HideRows()
Dim cell As Range
For Each cell In Range("J19:J33")
If Not isEmpty(cell) Then
If cell.Value = 0 Then
cell.EntireRow.Hidden = True
End If
End If
Next
End Sub
Hit F5to run the macro.
点击F5运行宏。
before
前
after
后