AW: versteh des nicht so ganz...
25.04.2011 12:39:41
Tino
Hallo,
ungetestet weil ich die Datei nicht nachbauen möchte, müsste es so gehen.
Private Sub CommandButton11_Click()
Dim varTMP As Variant, lngSp As Long
Dim iIndexTextBox As Integer, lngRow As Long
With Sheets(ComboBox10.Value)
varTMP = Application.Match(CLng(CDate(TextBox295.Text)), .Rows(4), 0)
If IsError(varTMP) Then
lngSp = .Cells(4, .Columns.Count).End(xlToLeft).Column + 1 'Zeile 4
If lngSp = 3 And .Cells(4, 2) = "" Then lngSp = 2 'zwingend immer B4 anfangen
Else
lngSp = varTMP
End If
If IsError(varTMP) Then .Cells(4, lngSp) = CDate(TextBox295.Text)
iIndexTextBox = 201
For lngRow = 5 To 98
.Cells(lngRow, lngSp) = .OLEObjects("TextBox" & iIndexTextBox).Object.Text
.OLEObjects("TextBox" & iIndexTextBox).Object.Text = "" 'Textbox leer
iIndexTextBox = iIndexTextBox + 1
Next lngRow
End With
End Sub
Private Sub TextBox295_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim varTMP As Variant
Dim iIndexTextBox As Integer, lngRow As Long
With Sheets(ComboBox10.Value)
If TextBox295.Text > "" Then _
varTMP = Application.Match(CLng(CDate(TextBox295.Text)), .Rows(4), 0) 'Zeile4
iIndexTextBox = 201
If TextBox295.Text > "" And Not IsError(varTMP) Then
For lngRow = 5 To 98
.OLEObjects("TextBox" & iIndexTextBox).Object.Text = .Cells(lngRow, varTMP).Value
iIndexTextBox = iIndexTextBox + 1
Next lngRow
Else
For lngRow = 5 To 98
.OLEObjects("TextBox" & iIndexTextBox).Object.Text = ""
iIndexTextBox = iIndexTextBox + 1
Next lngRow
End If
End With
End Sub
Gruß Tino