VBA Filter


SUBMITTED BY: Guest

DATE: July 11, 2013, 7:25 a.m.

FORMAT: Text only

SIZE: 1.3 kB

HITS: 923

  1. Sub Schaltfläche1_Klicken()
  2. Dim towns(1 To 5) As String
  3. Dim people(1 To 5) As String
  4. Dim filter_string As String
  5. filter_string = InputBox("Geben Sie ein Stadtfilter an", "Filter eingabe", "Berlin")
  6. Dim filter_people_string As String
  7. filter_people_string = InputBox("Geben Sie ein Personenfilter an", "Filter eingabe", "Peter")
  8. Dim read_cell As String
  9. Dim read_people_cell As String
  10. For i = 1 To UBound(towns)
  11. read_cell = Cells(i, 1)
  12. read_people_cell = Cells(i, 2)
  13. towns(i) = read_cell & "|" & read_people_cell
  14. Debug.Print towns(i)
  15. Next
  16. found_town = Filter(towns, filter_string, True)
  17. found_people = Filter(found_town, filter_people_string, True)
  18. Dim wohnen_string As String
  19. wohnen_string = "wohnt"
  20. If (UBound(found_people) + 1) > 1 Then
  21. wohnen_string = "wohnen"
  22. End If
  23. Cells(1, 3) = (UBound(found_people) + 1) & " " & filter_people_string & " " & wohnen_string & " in " & filter_string
  24. MsgBox (UBound(found_people) + 1) & " " & filter_people_string & " " & wohnen_string & " in " & filter_string
  25. End Sub

comments powered by Disqus