SVERWEIS2() ?
04.12.2009 09:51:48
ransi
Hallo Jörg
Pack diesen Code mal in Modul:
' **********************************************************************
' Modul: Sverweis_anders Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Public Function SVERWEIS2(Kriterium As String, _
Bereich As Range, _
SuchSpalte As Integer, _
ErgebnissSpalte As Integer, _
Optional Unikate As Boolean = True, _
Optional Trenner As String = ", ") As String
Dim arrTmp
Dim L As Long
Dim Mydic As Object
arrTmp = Bereich
Set Mydic = CreateObject("Scripting.Dictionary")
If Unikate = True Then
For L = 1 To UBound(arrTmp)
If arrTmp(L, SuchSpalte) = Kriterium Then Mydic(arrTmp(L, ErgebnissSpalte)) = 0
Next
SVERWEIS2 = Join(Mydic.keys, Trenner)
Else:
For L = 1 To UBound(arrTmp)
If arrTmp(L, SuchSpalte) = Kriterium Then Mydic(L) = arrTmp(L, ErgebnissSpalte)
Next
SVERWEIS2 = Join(Mydic.items, Trenner)
End If
End Function
Der Aufruf geht dann so:
Tabelle2
| A | B | C | D | E |
1 | | Produktbereich 1 | Produktbereich 2 | | Produkt A |
2 | Produkt A | 0GH | Q8U | | Produktbereich 2 |
3 | Produkt B | J6P | 7B6 | | Q8U, Q8U, TPA, Q8U |
4 | Produkt A | 7ZW | Q8U | | |
5 | Produkt B | NA7 | PJM | | |
6 | Produkt A | KAW | TPA | | |
7 | Produkt B | 94P | L3Z | | |
8 | Produkt A | 1QI | Q8U | | |
9 | Produkt B | ZF2 | LR6 | | |
10 | | | | | |
Formeln der Tabelle |
Zelle | Formel | E3 | =sverweis2(E1;A1:C20;1;VERGLEICH(E2;A1:C1;0); FALSCH) |
|
Excel Tabellen im Web darstellen >> Excel Jeanie HTML 4
Erklärt wirds hier:
http://www.j-hennekes.de/1729416.htm
ransi