I appologize for the first rendition of this post, I just pasted the Function directly from Excel's VBA project window. I did not realize that the formatting would be lost. I also wasn't aware that I could create code fences with backticks ` or tildes ~
I modified the Function to include the table Field name(s) and the contents of the Criteria1 Array when the type is ".Operator = xlFilterValues". Now instead of getting:
[:] AND [:=1]
I get
[Surname:=Gedye,=Sole,=Williams] AND [Active:=1]
Public Function AutoFilterCriteria(ByVal WholeTable As Range) As String
On Error Resume Next
If WholeTable.Parent.AutoFilter Is Nothing Then ' if no filter is applied
AutoFilterCriteria = "None"
On Error GoTo 0
Exit Function
End If
Dim LongStr As String, FirstOne As Boolean
LongStr = ""
FirstOne = False
Dim iFilt As Integer
For iFilt = 1 To WholeTable.Parent.AutoFilter.Filters.Count ' loop through each column of the table
Dim ThisFilt As Filter
Set ThisFilt = WholeTable.Parent.AutoFilter.Filters(iFilt) ' look at each filter
On Error Resume Next
With ThisFilt
If .On Then
If FirstOne Then LongStr = LongStr & " AND " ' Get column title
'The line below was modified from the original
LongStr = LongStr & "[" & Range("MainTable[#Headers]")(1, iFilt)
LongStr = LongStr & WholeTable.Parent.Cells(WholeTable.Row - 1, WholeTable.Column + iFilt - 1).Value & ":"
On Error GoTo Handle
If .Operator = xlFilterValues Then ' dont really care to enumerate multiples, just show "multiple"
'The line below was modified from the original
LongStr = LongStr & Join(.Criteria1, ",") & "]"
ElseIf .Operator = 0 Then
LongStr = LongStr & .Criteria1 & "]"
ElseIf .Operator = xlAnd Then
LongStr = LongStr & .Criteria1 & " AND " & .Criteria2 & "]"
ElseIf .Operator = xlOr Then
LongStr = LongStr & .Criteria1 & " OR " & .Criteria2 & "]"
End If
On Error GoTo 0
FirstOne = True
End If
End With
Next
AutoFilterCriteria = LongStr
On Error GoTo 0
Exit Function
Handle:
AutoFilterCriteria = "! Error !"
On Error GoTo 0
End Function
CodeRange = Application.Transpose(oSh.Range("packing_list[Code]").Value)Collectionfirst, and then converted into an array once the # of elements where known.MsgBox Join([Transpose(packing_list[Code])], "//")