AW: wenn Funktion in VBA Code
04.11.2014 11:00:04
fcs
Hallo ANAnas,
nachfogend ein Makro mit entsprechender Auswertung.
Falls die Prüfung für Spalte C (3) nicht relevant ist, dann kannst du sie weglassen.
Gruß
Franz
Sub MarkierenMehrfache()
Dim wks As Worksheet, Zeile As Long, intCount As Integer
Dim strZelle As String
Dim SpalteWert As Long, spalteErgebnis As Long
Set wks = ActiveSheet
SpalteWert = 2 'Spalte B - Spalte mit zu vergleichenden Werten
spalteErgebnis = 5 'Spalte E - Spalte mit Ergebnissen - kann auch identisch SpalteWert sein.
With wks
For Zeile = 4 To .Cells(.Rows.Count, SpalteWert).End(xlUp)
strZelle = .Cells(Zeile, SpalteWert).Text
If strZelle = .Cells(Zeile + 1, SpalteWert).Text _
And .Cells(Zeile, 3).Value = "I" Then
intCount = intCount + 1
.Cells(Zeile, spalteErgebnis).Value = "'" & strZelle & "-" & Format(intCount, "0")
Else
If intCount > 0 Then
'Wert ist identisch mit vorheriger Zeile
.Cells(Zeile, spalteErgebnis).Value = "'" & _
.Cells(Zeile, SpalteWert).Text & "-" & Format(intCount + 1, "0")
Else
.Cells(Zeile, spalteErgebnis).Value = "'" & strZelle
End If
intCount = 0
End If
Next
End With
End Sub