Excel VBA筛选/可见单元格 [英] Excel VBA Filtered/Visible Cell

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

问题描述

假设我有10行数据.我对数据应用了一些过滤器,对行号7和9进行了过滤 OR 可见.

Suppose I have 10 rows of data. I apply some filter to the data and row numbers 7 and 9 are filtered OR visible.

我要遍历数据(10行),并在空白列(假设列C)中仅输出字符串可见" (可见行)(即范围C7和范围C9).

I want to loop through the data (10 Rows) and output the string "Is Visible" in a blank column (suppose Column C), only for the Visible rows (i.e. Range C7 and Range C9).

推荐答案

选择要隐藏的前10行中的一些,然后尝试运行此行

Choose some of the first 10 rows to hide, and then try running this

Option Explicit

Sub CheckIfVisible()

Dim i As Integer, x As Integer
x = 0
For i = 1 To 10
    With Excel.ThisWorkbook.ActiveSheet
        If .Rows(i).EntireRow.Hidden Then
        Else
            .Cells(15 + x, 1) = "Row " & i & "is visible"
            x = x + 1
        End If
    End With
Next i

End Sub

这是您要寻找的循环吗?
也许您可以向我们展示您的Loop,以便我们查看您的问题出在哪里?

Is this the sort of loop you're looking for?
Maybe you can show us your Loop so we can see where your problem is?

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

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