title: Count selected rows after auto filter
body: <p>When my data are raw and unfiltered I can select them and <code>Selection.Rows.Count</code> returns the valid number.</p>
  <p>After the AutoFilter it returns a number as if I selected the rows that were not visible, even though <code>Selection.Copy</code> does not copy other than selected rows.</p>
  <p>How do I get the valid count of selected rows?</p>
  <p>I tried <code>Selection.SpecialCells(xlCellTypeVisible).Rows.Count</code>.</p>
  <p><strong>EDIT</strong></p>
  <p>I use filter in another macro and then select by hand rows I want to add to another sheet.</p>
  <p>I did two buttons, one to filter my table and the second to move selected rows to another sheet.</p>
  <pre><code>Sub ajout_commande()
  Set DataSheet = ThisWorkbook.Worksheets(&quot;Prepa Commandes&quot;)
  Dim a As Range, b As Range
  Set a = Selection
  i = 0
  s = Selection.SpecialCells(xlCellTypeVisible).Count
  For Each b In a.Rows
      i = i + 1
      DataSheet.Cells(6, 1).EntireRow.Insert
      DataSheet.Range(&quot;A1:Z1&quot;).Copy DataSheet.Cells(6, 1).EntireRow
  Next
  
  Dim r1 As Range, r2 As Range, r3 As Range
  Let copyrange1 = &quot;E1&quot; &amp; &quot;:&quot; &amp; &quot;I&quot; &amp; i
  Let copyrange2 = &quot;BK1&quot; &amp; &quot;:&quot; &amp; &quot;BM&quot; &amp; i
  Set r1 = a.Range(copyrange1)
  Set r2 = a.Range(copyrange2)
  Set r3 = Union(r1, r2)
  
  r3.Copy
  DataSheet.Cells(6, 1).PasteSpecial xlPasteValues
  MsgBox s &amp; &quot; and &quot; &amp; i
  
  End Sub
  </code></pre>
  <p>Here my table is filtered and I want to add selected rows to another sheet but the Selection.Rows.Count returns more rows than I selected because it counts the non visible rows, even though <code>Selection.copy</code> works.<br />
  <a href="https://i.stack.imgur.com/T2pht.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T2pht.png" alt="enter image description here" /></a></p>
  <p>For this example Selection.Rows.Count = 28 because of non visible rows between rows 10 and 20, 21 and 25 etc.</p>
  <p>Is there a function to get the number I want (on this image 16)?</p>