home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Modul11"
- Public Suchstring, spalte1, spalte2, spalte3 As String
- Sub BlattFiltern()
- Attribute BlattFiltern.VB_Description = "Makro am 06.08.2003 von F.O.D. aufgezeichnet"
- Attribute BlattFiltern.VB_ProcData.VB_Invoke_Func = " \n14"
- Dim filter_1(10000)
- Dim filter_2(10000)
- Dim filter_3(10000)
- UserForm1.Show
-
- If Suchstring = "" Then
- MsgBox "Die Eingabe des Suchbegriffs ist notwendig."
- Exit Sub
- End If
-
- If spalte1 = "" Then
- MsgBox "Die Eingabe der Suchspalte ist notwendig."
- Exit Sub
- Else
- sp1 = Asc(UCase(spalte1)) - 64
- If sp1 < 1 Then
- MsgBox "Spalten bitte mit Buchstaben (A, B, C...) angeben."
- spalte1 = ""
- Exit Sub
- End If
- End If
-
- If spalte2 <> "" Then sp2 = Asc(UCase(spalte2)) - 64
- If spalte3 <> "" Then sp3 = Asc(UCase(spalte3)) - 64
-
- If sp2 < 0 Or sp3 < 0 Then
- MsgBox "Spalten bitte mit Buchstaben (A, B, C...) angeben."
- spalte2 = ""
- spalte3 = ""
- Exit Sub
- End If
-
- Suchstring = UCase(Suchstring)
- For Each tabelle In ActiveWorkbook.Sheets
- If Not tabelle.Name = "PCW-Filter" Then
- tabelle.Select
- zeile = ActiveCell.SpecialCells(xlLastCell).Row
- For x = 1 To zeile
- inhalt = UCase(Cells(x, sp1).Value)
- If InStr(inhalt, Suchstring) Then
- y = y + 1
- filter_1(y) = Cells(x, sp1).Value
- If spalte2 <> "" Then filter_2(y) = Cells(x, sp2).Value
- If spalte3 <> "" Then filter_3(y) = Cells(x, sp3).Value
- End If
- Next
- End If
- Next
-
- For Each wsheet In Worksheets
- If wsheet.Name = "PCW-Filter" Then
- Sheets("PCW-Filter").Select
- Columns("A:C").Select
- Selection.ClearContents
- deldone = 1
- End If
- Next
-
- If deldone = 0 Then
- Set neu = Worksheets.Add
- neu.Name = "PCW-Filter"
- Sheets("PCW-Filter").Select
- End If
-
- Range("A1:C2").Select
- With Selection.Font
- .Size = 14
- .Bold = True
- End With
- Cells(1, 1).Value = "Suche in Spalte " & UCase(spalte1) & ": " & Suchstring
- If spalte2 <> "" Then Cells(1, 2).Value = "Spalte " & UCase(spalte2)
- If spalte3 <> "" Then Cells(1, 3).Value = "Spalte " & UCase(spalte3)
- For z = 1 To y
- Cells(z + 2, 1).Value = filter_1(z)
- If spalte2 <> "" Then Cells(z + 2, 2).Value = filter_2(z)
- If spalte3 <> "" Then Cells(z + 2, 3).Value = filter_3(z)
- Next
- Range("A:C").Columns.AutoFit
- Range("A1").Select
- Suchstring = ""
- spalte1 = ""
- spalte2 = ""
- spalte3 = ""
- deldone = 0
- End Sub
-