also ich baue grade ein Makro, dass den Input und Output ermitteln soll und dazu es in "Varianten" unterteilen soll.
Das beginnt mit einer Datumseingabe "von bis" und überprüft die Datensätze auf 2 Tabellenblättern nach Übereinstimmungen.
Das eine Tabellenblatt "R1" enthält den Input. Hier zählt er wenn:
- der Datumsstempel innerhalb des eingegebenen Zeitraums liegt
- der Masterbarcode in Spalte B sich ändert (also wenn in B11 was anderes als in B10 steht, dann nimm die B10-Zeile)
- der Wert in Spalte i größer als 0 ist
Das Zählen insoweit funktioniert schon einwandfrei, jedoch möchte ich das nicht nur als Gesamtzahl sondern unterteilt in Gruppen anhand des Wertes in Spalte A haben.
Also statt "Input 50" dann "Input: 1110 - 10, 2220 - 15...". Das ganze im Tabellenblatt InputOutput.
Makro:
Sub InOut()
Dim StartDatum As Date, EndDatum As Date, i As Integer, j As Long, inp As Long, outp As Long, _
logMax As Long, logRow As Long, rMax As Long, rRow As Long
StartDatum = DatumInOut.datumvon
EndDatum = DatumInOut.datumbis
Set wsinout = ActiveWorkbook.Sheets("InputOutput")
Set wslog = ActiveWorkbook.Sheets("LogImport")
wsinout.Cells.Clear
For i = 1 To 4
Set wsroh = ActiveWorkbook.Sheets("R" & i)
With wsroh
'Anzahl der Zeilen in LogImport ermitteln
rMax = Application.Max(2, .Cells(.Rows.Count, 1).End(xlUp).Row)
For rRow = 2 To rMax
If .Cells(rRow, 15) >= StartDatum And .Cells(rRow, 15) _
.Cells(rRow + 1, 2) And .Cells(rRow, 9) > 0 Then inp = inp + 1
Next rRow
End With
Next i
With wslog
'Anzahl der Zeilen in LogImport ermitteln
logMax = Application.Max(2, .Cells(.Rows.Count, 1).End(xlUp).Row)
For logRow = 2 To logMax
'If .Cells(logRow, 11) >= StartDatum And .Cells(logRow, 11) .Cells(logRow + 1, 2) And .Cells(logRow, 9) > 0 Then inp = inp + 1
If .Cells(logRow, 11) >= StartDatum And .Cells(logRow, 11) .Cells(logRow + 1, 2) Then outp = outp + 1
Next logRow
End With
MsgBox ("Input: " & inp)
MsgBox ("Output: " & outp)
End Sub
BspDatei:https://www.herber.de/bbs/user/125519.xlsx
Also es ist schon offensichtlich dass ein SVerweis sinnvoll wäre, nach dem Sinne, wenn im Ausgabeblatt der Wert aus Spalte A schon vorhanden ist, dann addiere um 1, sonst füge den Wert ins Ausgabeblatt.
Nur kriege ich das nicht umgesetzt, zu wenig SVerweis Erfahrungen.
Kann mir jmd einen Denkanstoß geben?
Freundliche Grüße
Burak