V
V
V2016-04-15 12:06:22
Visual Basic
V, 2016-04-15 12:06:22

How to read updated cell values ​​after applying a filter in VBA?

In column B I have 1000 values. Also manually made a filter that filters the amount by month. There is code that counts the number:
Sub flight_plot()
one = 0
For Each c in ActiveWorkbook.Worksheets("Account").Range("b8:b1000)
If c= "something" Then
one = one + 1
End if
Next
However when I apply the filter and the quantity changes, the macro reads the previous quantity.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Fedoryan, 2016-04-15
@ermolushka

Add this line to the condition:
Your code is slightly modified: several numbers in a column, only "5" values ​​are filtered

Sub filter()
    Dim one As Integer
    Dim c As Variant
    one = 0
    For Each c In ActiveWorkbook.Worksheets("Лист1").Range("C6:C19")
        If (c <> "") And (Rows(c.Row).Hidden = False) Then
            one = one + Int(c)
        End If
    Next
    MsgBox (Str(one))
End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question