如何分析过滤范围内第一个细胞的值?特殊细胞?

时间:2017-06-22 01:30:55

标签: excel-vba range vba excel

我无法检查过滤列中标题下方的第一个单元格是否包含LT。我认为特殊细胞放置不正确。

HeaderRow = wb.Sheets(" Sheet1")。AutoFilter.Range(1).Row

FiltRng = wb.Sheets("Sheet1").Range(HeaderRow  + 1).SpecialCells(xlCellTypeVisible).value

        If FiltRng Like "*LT*" Then
MsgBox "It has LT"

1 个答案:

答案 0 :(得分:1)

我能找到的唯一方法是检查第一个非标题行是否可见:

  • 如果是的话,从那里获取单元格
  • 如果没有,请从可见 SpecialCells
  • 获取下一个区域
  • 如果只有一个这样的区域,那就是标题行,这意味着自动过滤器与任何东西都不匹配,所以一切都被隐藏了。

C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:318:in `rescue in establish_connection': Timed out connecting to Redis on localhost:6379 (Redis::CannotConnectError)
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:311:in `establish_connection'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:91:in `block in connect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:273:in `with_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:90:in `connect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:256:in `with_socket_timeout'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:267:in `without_socket_timeout'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:122:in `call_loop'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/subscribe.rb:35:in `subscription'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/subscribe.rb:12:in `subscribe'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:2587:in `_subscription'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:2008:in `block in subscribe'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:37:in `block in synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:37:in `synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:2007:in `subscribe'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/actioncable-5.0.3/lib/action_cable/subscription_adapter/redis.rb:75:in `block in listen'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis/client.rb:273:in `with_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:43:in `block in with_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:37:in `block in synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:37:in `synchronize'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:42:in `with_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/redis-3.2.0/lib/redis.rb:49:in `without_reconnect'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/actioncable-5.0.3/lib/action_cable/subscription_adapter/redis.rb:72:in `listen'
        from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/actioncable-5.0.3/lib/action_cable/subscription_adapter/redis.rb:146:in `block in ensure_listener_running'

C:\Users\Michael\Desktop\ruby\chat>