AW: Text bedingt verketten (VBA-Funktion)
16.11.2006 23:45:51
Erich
Hallo Gregor,
dann so:
| B | C | D | E | F | G | H |
1 | Fritz1 | | | | | nein | Friedrich3 Friedrich5 Friedrich6 Fritz8 Fritz11 Fritz13 |
2 | Friedrich2 | | | | ja | | |
3 | Friedrich3 | | | | vielleicht ja | nein | Friedrich3 und Friedrich5 und Friedrich6 und Fritz8 und Fritz11 und Fritz13 |
4 | Friedrich4 | | | | ja | | |
5 | Friedrich5 | | | | ja | aber nein | |
6 | Friedrich6 | | | | ja doch | nein | |
7 | Friedrich7 | | | | ja ja | | |
8 | Fritz8 | | | | wenn ja | nein | |
9 | Fritz9 | | | | ja | | |
10 | Fritz10 | | | | | | |
11 | Fritz11 | | | | ja | nein | |
12 | Fritz12 | | | | vielleicht | nein | |
13 | Fritz13 | | | | ja | nein | |
Formeln der Tabelle |
Zelle | Formel | H1 | =VerketteSp1wennInSp2undInSp3("B";" ";"F";"ja";"G";"nein") | H3 | =VerketteSp1wennInSp2undInSp3("B";" und ";"F";"ja";"G";"nein") |
|
mit der Funktion
Function VerketteSp1wennInSp2undInSp3( _
Sp1 As String, Tz As String, _
Sp2 As String, W2 As String, _
Sp3 As String, W3 As String) As String
Dim zz As Long, tmp As String
Application.Volatile
For zz = 1 To Cells(Rows.Count, Sp1).End(xlUp).Row
If Not IsEmpty(Cells(zz, Sp1)) _
And Not IsEmpty(Cells(zz, Sp2)) And Not IsEmpty(Cells(zz, Sp3)) And _
InStr(Cells(zz, Sp2), W2) > 0 And InStr(Cells(zz, Sp3), W3) > 0 Then
If RTrim(tmp) > "" Then tmp = tmp & Tz
tmp = tmp & Cells(zz, Sp1)
End If
Next zz
VerketteSp1wennInSp2undInSp3 = tmp
End Function
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-Lintfort