AW: Userform Ausgabe in die richtige Zeile
08.02.2023 13:31:56
peterk
Hallo
Am Besten Du fügst wie gewohnt ein und sortierst dann die Tabelle nach Spalte A.
Private Sub Eingabe_Click()
Dim last As Integer 'Erste freie Zeile ausfindig machen
last = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row + 1 'ab dritte Zeile : Du ermittelst den Row Count in der 3. Spalte!!
Cells(last, 1).Value = AK_Nr
Cells(last, 2).Value = AK_Bezeichnung
If WGTA.Value = True Then Cells(last, 3) = Cells(last, 3) & " A"
If WGTC.Value = True Then Cells(last, 3) = Cells(last, 3) & " C"
If WGTE.Value = True Then Cells(last, 3) = Cells(last, 3) & " E"
If WGTD.Value = True Then Cells(last, 3) = Cells(last, 3) & " D"
If WGTB.Value = True Then Cells(last, 3) = Cells(last, 3) & " B"
Cells(last, 3) = Replace(Trim(Cells(last, 3)), " ", ", ")
If IsNumeric(SollZeit) Then Cells(last, 4) = CDbl(SollZeit)
If IsNumeric(IstZeit) Then Cells(last, 5) = CDbl(IstZeit)
If IsNumeric(MA) Then Cells(last, 6) = CDbl(MA)
If IsNumeric(KontNr) Then Cells(last, 7) = CDbl(KontNr)
Cells(last, 8).Value = Replace(Bemerkung, Chr(13), "")
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add2 Key:=Range( _
"A3:A" & last), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveSheet.Sort
.SetRange Range("A3:H" & last)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Peter