in einer Tabelle suche ich mit folgendem VBA Code nach einem Datum...oder besser ich versuche es.
Die Suche löse ich per Schaltfläche in einem Formular aus. Die gesuchten Werte werden auch in das Formular übertragen.
Trage ich in die TextBox1 den "Excel Wert" also z.B. 39456 und habe ich auch das Sheet so formatiert klappt die Suche. Mit dem Datum tt.mm.jj klappt es aber nicht.
Private Sub CoBuMainSCsearch_Click()
Set frm2 = UserForm2
With frm2
Sheets("SCdata2").Select
Range("G:G").Select
On Error GoTo fehler
Selection.Find(What:=.TextBox1.Value, _
After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
.TextBox2.Value = ActiveCell.Offset(0, 5).Value
.TextBox3.Value = ActiveCell.Offset(0, -6).Value
.TextBox4.Value = ActiveCell.Offset(0, -3).Value
.TextBox5.Value = ActiveCell.Offset(0, -4).Value
.TextBox7.Value = ActiveCell.Offset(0, 1).Value
.TextBox6.Value = ActiveCell.Offset(0, -2).Value
.TextBox8.Value = ActiveCell.Offset(0, 2).Value
.TextBox20.Value = ActiveCell.Offset(0, 6).Value
.TextBox21.Value = ActiveCell.Offset(0, 7).Value
.TextBox22.Value = ActiveCell.Offset(0, 8).Value
.TextBox23.Value = ActiveCell.Offset(0, 9).Value
.TextBox24.Value = ActiveCell.Offset(0, 10).Value
'If ActiveCell.Offset(0, 5).Value = "1" _
'Then .OpBuSCyes.Value = True
'Else .OpBuSCno.Value = False Range("A1").Select
' Exit Sub
fehler:
MsgBox "Keine Reisedaten zu Datum : " & _
.TextBox1.Value & " vorhanden!"
End With
End Sub
Wäre toll wenn mir jemand sagen kann wie das Datum umgewandelt werden muss.
Merci