Hi Everyone, I have created this Blog to help people who Loves excel and wish to learn VBA code, It seems to me that excel is beyond our imagination. So we just take the first column of the autofilter range and count the number of visible cells. We need to include the header row in our counted range because SpecialCells will throw an error if no cells are found, which we want to avoid.The Cells property will give you an accurate count even if the Range has multiple Areas, unlike the Rows property. We have to subtract 1 to remove the header row. Set r = Range('data').Columns(1).SpecialCells(xlCellTypeVisible) Range('Data').AutoFilter field:=1, Criteria1:=65 Mandeepbaluja:– Hello Everyone!! Hope You’re well,OK Let’s Start Have You ever face a situation at where you wish to count numbers of filtered rows after applying filter with VBA. OK,Let me tell you the way and the glitch mostly people do in this case.ġ) If filtered values are adjacent it will give you correct result with no of rows.Ģ)Always leave the top row while calculating no of rows otherwise it will be considered as first visible cell and gives only 1 count every time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |