VBA Gruppierung
15.09.2015 15:34:19
Roffel89
ich würde gerne eine bestimmte Gruppierung durchführen.
Hier meine zwei Tabellenblätter
Die Summary, in der gearbeitet wird:
und mein Datensatz im Tabellenblatt: 30112015
und hier mein Code:
Public Sub testClient()
Dim sheet As String
'sheet selector
sheet = "30112015"
'Summary Zeile mit Datum und Anzahl der Datensätze
Dim summary As Integer
summary = checkList(sheet, 13, "Fall 4: Statusveränderung negativ")
summary = summary + checkList(sheet, 12, "Fall 3: Statusveränderung positiv")
summary = summary + checkList(sheet, 11, "Fall 2: Keine Statusveränderung (negativ)")
summary = summary + checkList(sheet, 10, "Fall 1: Keine Statusveränderung (positiv)")
Call newLineAndFormat
Sheets("Summary").Cells(15, 2).Value = "=TODAY()"
Sheets("Summary").Cells(15, 5).Value = summary
Sheets("Summary").Activate
End Sub
Function checkList(sheet As String, caseColumn As Integer, Optional label As String = "") As IntegerDim currentRow As Long
Dim counter As Integer
'Checking List
For currentRow = Sheets(sheet).Cells.SpecialCells(xlLastCell).Column To 2 Step -1
If (Sheets(sheet).Cells(currentRow, caseColumn).Value = "True" Or _
Sheets(sheet).Cells(currentRow, caseColumn).Value = "Wahr") Then
Call newLineAndFormat
Sheets("Summary").Cells(15, 4).Value = Sheets(sheet).Cells(currentRow, 1).Value
counter = counter + 1
End If
Next currentRow
'Summary row
Call newLineAndFormat
Sheets("Summary").Cells(15, 4).Value = label
Sheets("Summary").Cells(15, 5).Value = counter
Sheets("Summary").Activate
checkList = counter
End Function
Private Sub newLineAndFormat()
Sheets("Summary").Activate
Sheets("Summary").Rows("15:15").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Summary").Range("16:16").Copy
Sheets("Summary").Rows("15:15").PasteSpecial Paste:=xlPasteFormats
Sheets("Summary").Range("B15").Select
Application.CutCopyMode = False
End Sub
Und jetzt ist mein Ziel: das er Fall 3 und Fall 4, die Namen unten den Fallen gruppiert. Das man diese bei Bedarf auf und zuklappen kann.
Und eine Gruppierung über alle 4 Fälle hinweg, sodas man nur meine Summary Zeile sieht.
Wie gehe ich hier vor?
Bin über jede Hilfe dankbar.
VG