![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
Using code, I have used autofilter to filter the data. I now want to count how many rows that I am left with and pinpoint the activecell to the first cell of the first row of the filtered data. Hope someone can help.
Many thanks Matt |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
This may help you out. Amend as required. Sub FilteredRow_Count() '// IFM Dim FilteredRg As Areas Dim rArea As Range Dim dRowcount As Double Dim sStCell As String Dim Flag As Boolean '// [A2] is the start of the filtered Data Set FilteredRg = Range([A2], [A2].End(xlDown)).SpecialCells(xlVisible).Areas '// make sure we hit the right item Flag = True For Each rArea In FilteredRg '// get 1st cell address If Flag Then sStCell = rArea.Item(1).Address: Flag = False dRowcount = dRowcount + rArea.Rows.Count Next MsgBox dRowcount & ":" & sStCell '// Cleanup Set FilteredRg = Nothing End Sub |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|