VBA仅通过可见单元格循环 [英] VBA Loop through Visible cells only

查看:135
本文介绍了VBA仅通过可见单元格循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用下面的代码遍历每一行,但是我只想遍历行10 -194内的B列中的可见单元格(因为我已经滤除了要忽略的值).有人知道我会怎么做吗?

I am using the below code to loop through each row however I only want to loop through visible cells in Column B (as I have filtered out the values I want to ignore) ranging from Row 10 -194. Does anyone know how I would do this?

For X = 192 to 10 Step -1
    If Range("B" & X).Text = "" Then **This needs to change to visible cells only but not sure how!
        Code required insert here
    Else
    End If
Next X

推荐答案

行高为0表示该行是隐藏的.所以你可以检查一下

A row height of 0 means the row is hidden. So you could check for that

For X = 192 to 10 Step -1
    If Worksheets("Sheet1").Rows(X).RowHeight > 0 Then
        Code required insert here
    End If
Next X

假设您正在处理"Sheet1".

Assuming you are dealing with "Sheet1" of course.

这篇关于VBA仅通过可见单元格循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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