AW: Liste filtern,Filterinhalt in neue Datei kopieren
29.01.2014 11:10:32
fcs
Hallo Darius,
verwende für alle Summen und Zwischensummen die Funktion TEILERGEBNIS und gib immer Zellbereiche und nie Einzelzellen an.
Beispiel:
Position Feld02 Anzahl Einzelpreis Gesamt
1 Text001 =TEILERGEBNIS(9;E10:E16)
1.1 Text002 =TEILERGEBNIS(9;E11:E12)
1.1.1 Text003 2 300 =C11*D11
1.1.2 Text004 5 100 =C12*D12
1.2 Text005 =TEILERGEBNIS(9;E14:E16)
1.2.1 Text006 1 120 =C14*D14
1.2.2 Text007 1 222 =C15*D15
1.2.3 Text008 1 132 =C16*D16
2 Text009 =TEILERGEBNIS(9;E18:E22)
2.1 Text010 1 567 =C18*D18
2.2 Text011 =TEILERGEBNIS(9;E20:E22)
2.2.1 Text012 2 123 =C20*D20
2.2.2 Text013 2 321 =C21*D21
2.2.3 Text014 =C22*D22
3 Text015 1 1234 =C23*D23
Summe =TEILERGEBNIS(9;E9:E24)
Die Positionsnummern kann man nur neu generieren per Makro.
Ich hab es mal in das Makro eingebaut. Das ist jetzt komplizierter als alles vorherige.
Gruß
Franz
Sub Copy_plus_Filtern_3()
Dim wksListe As Worksheet
Dim Zeile As Long, Zeile_L As Long
Dim rng As Range
Const Zeile_Titel As Long = 8 'Zeile mit den Spaltentitel im Blatt mit allen Punkten
Const Spalte_X As Long = 10 ' Spalte J - Spalte in der die zu filternden Zeilen _
mit x oder anders markiert werden..
ActiveWorkbook.Worksheets("AllePunkte").Copy 'Tabellenblatt mit allen Punkten
Set wksListe = ActiveSheet
With wksListe
.Name = "Preisliste"
'letzte Zeile mit Daten ermitteln
Set rng = .Cells.Find(What:="*", after:=.Cells(1, 1), LookIn:=xlFormulas, _
lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious)
If rng Is Nothing Then Exit Sub Else Zeile_L = rng.Row
'leere Zellen in der Markierungspalte suchen und ganze Zeilen löschen
With .Range(.Cells(Zeile_Titel + 1, Spalte_X), .Cells(Zeile_L, Spalte_X))
If Application.WorksheetFunction.CountBlank(.Cells) > 0 Then
.SpecialCells(xlCellTypeBlanks).EntireRow.Delete shift:=xlShiftUp
End If
End With
.Columns(Spalte_X).Delete
'Positionen neu nummerieren in Spalte 1 (A)
Dim intNr(1 To 4) As Integer, strPos(1 To 4) As String
Dim intStufe As Integer, intI As Integer, strText As String
'letzte Zeile mit Daten ermitteln
Set rng = .Cells.Find(What:="*", after:=.Cells(1, 1), LookIn:=xlFormulas, _
lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious)
If rng Is Nothing Then Exit Sub Else Zeile_L = rng.Row
For Zeile = Zeile_Titel + 1 To Zeile_L
With .Cells(Zeile, 1) '1 anpassen, wenn Pos.-Nr. nicht in Spalte A
If IsNumeric(Left(.Text, 1)) Then
'Stufe aus Anzahl "." in Positionsnummer ermitteln
intStufe = Len(.Text) - Len(VBA.Replace(.Text, ".", "")) + 1
intNr(intStufe) = intNr(intStufe) + 1
Select Case intStufe
Case 1
strPos(intStufe) = "'" & Format(intNr(intStufe), "0")
Case Else
strPos(intStufe) = "." & Format(intNr(intStufe), "0")
End Select
For intI = intStufe + 1 To UBound(intNr)
strPos(intI) = ""
intNr(intI) = 0
Next
strText = ""
For intI = 1 To UBound(intNr)
strText = strText & strPos(intI)
Next
.Value = strText
End If
End With
Next
End With
End Sub