AW: Zählen ohne Duplikate mit 5 Bedingungen
03.07.2009 13:54:40
ransi
HAllo Jonathan
Hast du hierfür bereits eine Lösung?
So eine Spezielle Anwendung hat mit Sicherheit niemand fertig liegen.
Ist aber nicht schlimm, weil sowas ist schnell geschrieben.
Packe diesen Code mal in Modul:
' **********************************************************************
' Modul: Modul1 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Public Function my_UDF(Bereich As Range, arg1, arg2, arg3, arg4, arg5) As Long
Dim arr As Variant
Dim L As Long
Dim Dic1 As Object
Dim Dic2 As Object
Set Dic1 = CreateObject("Scripting.dictionary")
Set Dic2 = CreateObject("Scripting.dictionary")
arr = Bereich
For L = 1 To UBound(arr)
If arr(L, 1) = arg1 Then
If arr(L, 2) = arg2 Then
If arr(L, 3) <> arg3 Then
If arr(L, 4) = arg4 Then
If arr(L, 6) = arg5 Then
If Not Dic2.exists(arr(L, 5)) Then
Dic2(arr(L, 5)) = 0
Dic1(Join(Array(arr(L, 1), arr(L, 2), arr(L, 3), arr(L, 4), arr(L, 5), arr(L, 6)), vbTab)) = 0
End If
End If
End If
End If
End If
End If
Next
my_UDF = Dic1.Count
End Function
Der Aufruf geht dann so:
Tabelle1
| A | B | C | D | E | F |
1 | Daten1 | Daten2 | Daten3 | Daten4 | Daten5 | Daten6 |
2 | A | x | Text2 | D | Material1 | 3 |
3 | B | x | Text2 | D | Material1 | 2 |
4 | C | x | Text1 | F | Material2 | 3 |
5 | D | y | Text1 | F | Material2 | 3 |
6 | A | y | Text3 | D | Material3 | 3 |
7 | A | x | Text1 | F | Material4 | 3 |
8 | B | y | Text1 | F | Material4 | 2 |
9 | C | x | Text4 | D | Material5 | 2 |
10 | A | x | Text2 | D | Material6 | 3 |
11 | A | y | Text3 | D | Material1 | 3 |
12 | A | x | Text1 | D | Material6 | 3 |
13 | A | x | Text2 | D | Material6 | 3 |
14 | A | x | Text2 | D | Material1 | 3 |
15 | | | | | | |
16 | | | | | | |
17 | | | | | | |
18 | Kriterien | | | | | |
19 | Material muss sein: | | | | | |
20 | Spalte A | A | | | | |
21 | Spalte B | x | | | | |
22 | Spalte C | Text1 | | | | |
23 | Spalte D | D | | | | |
24 | Spalte F | 3 | | | | |
25 | | | | | | |
26 | Das Ergebnis sollte hier also 2 sein (Material ohne Duplikate) | | | | | |
27 | 2 | | | | | |
Formeln der Tabelle |
Zelle | Formel | A27 | =my_UDF(A2:F14;B20;B21;B22;B23;B24) |
|
Excel Tabellen im Web darstellen >> Excel Jeanie HTML 4
Teste mal selber "auf Herz und Nieren".
ransi