Hilfe zu einem Makro
Frank
Mittels folgendem Makro:
Private Sub cmdSuchen_Click()
Dim lng As Long
Dim i As Integer
Application.ScreenUpdating = False
With frmEingabe_DUZ
.ListBox1.Clear
Sheets("Hilfsdaten").Activate
i = 0
For lng = 3 To ActiveSheet.UsedRange.Rows.Count
If InStr(LCase(Cells(lng, 30).Value), LCase(.TextBox1.Value)) > 0 Then
.ListBox1.AddItem Cells(lng, 1).Text
.ListBox1.Column(0, i) = Cells(lng, 30).Text
.ListBox1.Column(1, i) = Cells(lng, 31).Text
.ListBox1.Column(2, i) = Cells(lng, 32).Text
.ListBox1.Column(3, i) = Cells(lng, 33).Text
.ListBox1.Column(4, i) = Cells(lng, 34).Text
.ListBox1.Column(5, i) = Cells(lng, 35).Text
.ListBox1.Column(6, i) = Cells(lng, 36).Text
.ListBox1.Column(7, i) = Cells(lng, 37).Text
.ListBox1.Column(8, i) = Cells(lng, 38).Text
.ListBox1.Column(9, i) = Cells(lng, 39).Row
i = i + 1
Else
End If
Next lng
End With
Application.ScreenUpdating = True
Dim zelle As Range
Dim sBegriff As Date
sBegriff = CDate(TextBox1)
If sBegriff = 0 Then Exit Sub
Set zelle = Worksheets("Hilfsdaten").Columns(30) _
.Find(sBegriff, LookAt:=xlWhole)
If zelle Is Nothing Then
MsgBox "Suchbegriff wurde nicht gefunden!"
Else
MsgBox "Suchbegriff befindet sich in Zelle " & _
zelle.Address
End If
zelle.Select
End Sub
suche ich in der Tabelle das in TextBox1 befindliche Datum. Ist dieses aber nicht in der Tabelle, bzw . die TextBox ist leer kommt die Fehlermeldung "Typen unverträglich". Wie kann ich diese Meldung umgehen und mir nur mittels MswgBox anzeigen lassen, dass der Suchbegriff nicht vorhanden ist?Danke für eure Hilfe!!!
Gruß Frank H.