Hi Y,
alles klar:
Sub button ()
Dim wkb As Workbook
Dim zeile As Long
Dim spalte As Long
Dim ersatz As Boolean
fin = TextBox4.Value
ersatz = CheckBox1.Value
Set wkb = Workbooks.Open("C:\Dokumente und Einstellungen\Desktop\Nwmgnt.xls")
wkb.Activate
Sheets("Neuwagen").Activate
If (fin <> "") Then
CheckBox1.Value = False 'ersatz
Set rangeobj = Cells.Find(What:=fin, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
Set rangeobj2 = Cells.Find(What:=fin, After:=ActiveCell, LookIn:=xlValues, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If rangeobj Is Nothing Then
MsgBox "Die FIN " + fin + " wurde nicht gefunden!"
Else
zeile2 = Sheets("ersatz").Cells(rangeobj2.Row, 1).Row
spalte2 = Sheets("ersatz").Cells(1, rangeobj2.Column).Column
zeile = Sheets("Neuwagen").Cells(rangeobj.Row, 1).Row
spalte = Sheets("Neuwagen").Cells(1, rangeobj.Column).Column
If (CheckBox1.Value = True) Then
Terminverwaltung.TextBox10.Value = Sheets("ersatz").Cells(zeile2, 20).Value
Terminverwaltung.TextBox8.Value = Sheets("ersatz").Cells(zeile2, 6).Value
Else:
Terminverwaltung.TextBox10.Value = Sheets("Neuwagen").Cells(zeile, 18).Value
Terminverwaltung.TextBox8.Value = Sheets("Neuwagen").Cells(zeile, 8).Value
End If
End If
End Sub ()
|