Also ich hab ne Suchmaske welche mir ein eine Excel-Mappe durchsucht - die Mappe hat selber 5 sheets - nur moechte ich das er mir nur ein betimmtes Sheet durchsucht - ich komm einfach ned drauf wo ich ihm sag er soll mir nur das eine Sheet durchsuchen und das Ergebnis anzeigen
Also wenn einer ne Idee hat - taet mich freuen!
Der Code bis jetzt schau so aus ->
###################################################
Option Explicit
Dim wks As Worksheet
Dim wkb1, wkb2 As Workbook
Dim XBlatt, wks2 As Worksheet
Dim XZeile As Long
Dim Suchart As String
Dim xOpt As Integer
Private Sub CheckBox1\_Click()
If CheckBox1.Value = True Then
Suchart = xlWhole
Else
Suchart = xlPart
End If
End Sub
Private Sub CheckBox2\_Click()
If CheckBox2.Value = True Then
ComboBox1.Enabled = False
Else
ComboBox1.Enabled = True
End If
End Sub
Private Sub CommandButton1\_Click()
Dim xSuche, xAdresse, xErste As String
Dim y As Boolean
Dim arr() As Variant
Dim rng As Range
Dim iCounter, iRowU As Integer
ListBox1.Clear
xSuche = TextBox1.Value
If xSuche = "" Then
MsgBox "Bitte erst einen Suchbegriff eingeben!", vbExclamation, "Achtung!"
Exit Sub
End If
If ComboBox1.Value = "" And CheckBox2.Value = False Then
MsgBox "Bitte geben Sie ein, wo der Begriff gesucht werden soll!", vbExclamation, "Achtung!"
Exit Sub
End If
For iCounter = 1 To ThisWorkbook.Sheets.Count
If CheckBox2.Value = True Or Worksheets(iCounter).Name = ComboBox1.Value Then
Set rng = Worksheets(iCounter).Cells.Find \_
(xSuche, LookAt:=Suchart, LookIn:=xlValues)
If Not rng Is Nothing Then
With Worksheets(iCounter)
xErste = rng.Address(False, False)
y = True
Do Until xAdresse = xErste
ReDim Preserve arr(0 To 19, 0 To iRowU)
'Stelle in Listbox - Stelle in Excel
arr(19, iRowU) = .Name
arr(17, iRowU) = rng.Address(False, False)
arr(0, iRowU) = .Cells(rng.Row, 2)
arr(1, iRowU) = .Cells(rng.Row, 3)
arr(2, iRowU) = .Cells(rng.Row, 5)
arr(3, iRowU) = .Cells(rng.Row, 14)
arr(4, iRowU) = .Cells(rng.Row, 16)
arr(5, iRowU) = .Cells(rng.Row, 18)
arr(6, iRowU) = .Cells(rng.Row, 4)
arr(7, iRowU) = .Cells(rng.Row, 7)
arr(8, iRowU) = .Cells(rng.Row, 8)
arr(9, iRowU) = .Cells(rng.Row, 9)
arr(10, iRowU) = .Cells(rng.Row, 10)
arr(11, iRowU) = .Cells(rng.Row, 11)
arr(13, iRowU) = .Cells(rng.Row, 12)
arr(14, iRowU) = .Cells(rng.Row, 13)
arr(15, iRowU) = .Cells(rng.Row, 17)
arr(16, iRowU) = .Cells(rng.Row, 15)
arr(18, iRowU) = .Cells(rng.Row, 6)
iRowU = iRowU + 1
Set rng = .Cells.FindNext(After:=rng)
xAdresse = rng.Address(False, False)
Loop
xAdresse = ""
xErste = ""
End With
End If
End If
Next iCounter
If y = False Then
MsgBox "Der Suchbegriff wurde nicht gefunden!"
Else
ListBox1.Column = arr
End If
End Sub
Private Sub CommandButton2\_Click()
Unload Me
End Sub
Private Sub CommandButton3\_Click()
Dim iCounter, xCounter As Long
Set wkb1 = ThisWorkbook
Set wkb2 = Workbooks.Add(1)
Set wks2 = wkb2.Sheets(1)
wkb1.Activate
For iCounter = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(iCounter) And xOpt = 1 Or xOpt = 2 Then
Set XBlatt = Sheets(ListBox1.List(iCounter, 0))
XZeile = Range(ListBox1.List(iCounter, 1)).Row
xCounter = xCounter + 1
XBlatt.Rows(XZeile).Copy wks2.Rows(xCounter)
End If
Next iCounter
wks2.Activate
End Sub
Private Sub ListBox1\_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Integer
If ListBox1.ListIndex \>= 0 Then
For i = 0 To ListBox1.ColumnCount - 1
arrTxt(i + 1) = ListBox1.List(ListBox1.ListIndex, i)
Next
UserForm6.Show
End If
End Sub
Private Sub OptionButton1\_Click()
xOpt = 1
End Sub
Private Sub OptionButton2\_Click()
xOpt = 2
End Sub
Private Sub UserForm\_Initialize()
For Each wks In Worksheets
If wks.Name ActiveSheet.Name Then ComboBox1.AddItem wks.Name
Next
Suchart = xlPart
xOpt = 1
End Sub
#############################################################
Gruss Rolf
[MOD] Pre-Tags eingefügt.