Option Explicit
Private Function format_dn(ByVal DN As String) As String
Dim T$, N&, Y, i
Set Y = CreateObject("Scripting.Dictionary")
For i = 1 To Len(DN) - 5
T = Mid(DN, i, 8): N = Val(T): T = N
If T Like "2#######" Or T Like "3#######" Then Y(T & "") = ""
T = Mid(T, 1, 6)
If T Like "2#####" Or T Like "3#####" Then Y(T & "") = ""
Next
If Y.Count = 0 Then
format_dn = ""
Else
format_dn = Join(Y.KEYS, vbCrLf)
End If
Set Y = Nothing
End Function