简体   繁体   English

按CBool​​列隐藏,不起作用

[英]Hide by CBool Columns, not working

Does anybody know, why this code isn't polite and hiding my columns by unknown rule? 有人知道,为什么这段代码不客气,并以未知的规则隐藏我的专栏吗?

Sub EmptyCol()
Call UnlockS

Dim Table As Range:     Set Table = Range("O_List")
Dim Col As Range
Dim Emp As Boolean

Dim c As Long
'Table.Columns.hide = False
With Table
    For c = 4 To .Columns.Count
    Set Col = .Columns(c)
        If (Application.CountIf(Col, "")) = (.Rows.Count) Then Emp = True
        .Columns(c).EntireColumn.Hidden = CBool(Emp)

    Next c
End With

Call L_ORDER
End Sub

v1 v1

    for c = 1 to .columns.count
        .columns(c).entirecolumn.hidden = not cbool(application.counta(.columns(c)))

Its edited code from my previous post, but now I know that isn't working. 它是我以前的帖子中编辑的代码,但现在我知道它不起作用。 It hides also not blank colums. 它也隐藏不空白的列。 Thx for your help. 谢谢您的帮助。

Sub EmptyCol()
    Call UnlockS

    Dim Table As Range:     Set Table = Range("O_List")
    Dim Col As Range
    Dim Emp As Boolean

    Dim c As Long
    Table.Columns.Hidden = False
    With Table
        For c = 4 To .Columns.Count
            .Columns(c).EntireColumn.Hidden = _
                        (Application.CountA(.Columns(c)) = 0)
         Next c
    End With

    Call L_ORDER
End Sub

I don't see where you set Emp back to false. 我看不到将Emp重新设置为false的位置。 Once it finds a positive result for the if, it's going to hide every column from that point forward. 一旦找到if的阳性结果,它将隐藏该点以后的每一列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM