EXCEL,关于满足条件时自动隐藏某行,不满足条件时不隐藏的VBA

比如,A1单元格为“”,则隐藏第1行,A2单元格为“”,则隐藏第2行,以此类推。

sub test()

dim rg as range
for i=1 to cells(rows.count,1).end(3).row
if cells(i,1)="" then

if rg is nothing then
set rg=rows(i)
else
set rg=union(rg,rows(i))
end if
end if
next i
rows.Hidden=false '全部显示
rg.EntireRow.Hidden=true '隐藏相关行
end sub追问

谢谢大侠!
我想把整个A列里面值为“”的单元格所对应的行全部隐藏应该怎么写

温馨提示:答案为网友推荐,仅供参考