title: Excel VBA Concatenate only visible cells of filtered column. Test code included
body: <p>Good day all,</p>
  
  <p>I'm trying to concatenate a filtered column into a single cell separated with commas. I know little about coding, the code provided are by others after hours of searching.</p>
  
  <p>So far, this function works but also concatenates invisible, filtered out cells:</p>
  
  <pre><code>Function test1(myRange As Range)
  Dim aOutput
  For Each entry In myRange
      If Not IsEmpty(entry.Value) Then
          aOutput = aOutput &amp; entry.Value &amp; ", "
      End If
  Next
  test1 = Left(aOutput, Len(aOutput) - 1)
  End Function
  </code></pre>
  
  <p>And this one works well where it will also remove duplicates from the range, but has the same problem:</p>
  
  <pre><code>Function test2(ByRef rRng As Range, Optional ByVal sDelim As String = ", ") As String
  Dim oDict As Object
  Dim rCell As Range
  Dim sTxt As String
  Set oDict = CreateObject("Scripting.Dictionary")
  With oDict
      For Each rCell In rRng
          If .Exists(rCell.Text) Then
              'Do nothing
          Else
              .Add rCell.Text, rCell.Text
              sTxt = sTxt &amp; sDelim &amp; rCell.Text
          End If
      Next rCell
  End With
      test2 = Mid(sTxt, Len(sDelim) + 1)
  End Function
  </code></pre>
  
  <p>Is it possible to alter the two functions to ignore invisible, filtered out cells in a column?</p>
  
  <p>Thanks for reading,</p>
  
  <p>Brian</p>