macro loop through visible rows after filter

  • Hi,

    I know very little in macros and I am struggling with this code. It would be great if any one help me in this.
    I have a filtered data in an excel spread sheet on 1 of the columns, now I need to create a loop on the visible/filtered data so that I can search for a value in one of the columns and I can get the result. Here is my code.

    the issue I am facing is , I have 17 rows filtered out of 49 rows. the above for .. each .. is looping only twice. It is not searching the 17 rows.

    MODERATOR NOTE - please remember to use code tags in future as per forum rules.

  • Re: macro loop through visible rows after filter

    I don't know what you are doing, your code is a little too confusing for me to spend too much time. If you care to explain to me in simple terms what you are trying to do, I might be able to help you.

    Here's something that jumps right out at me.

    For h = 2 To lcount - 1
                                schText1 = rngarea.Range("M" & lcount - 1)
                                If InStr(schText1, "Expected record count") Then
                                intPos1 = InStr(1, schText1, "):")
                                ep.Range("D" & Sheet6Row) = Right(schText1, (Len(schText1) - intPos1) - 1)
                                End If

    Every time this loops, lcount - 1 is the same number, it never changes.

    It's like saying For h = 2 To 100.

    h changes, but the second number is always 100. I think you meant to use h where you have lcount - 1, in the second line?

    You should rethink this section of code.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!