ich habe in einem Dokument weiße, hellgrüne und gelbe Zellen. Von diesen möchte ich gerne nur die gelben sowie hellgrünen markieren und dann entsprechend bearbeiten. Hierzu habe ich folgenden Code aus diesem Forum gefunden. Kann man das so anpassen, dass er nur "hellgrüne" und "gelbe" Zellen markiert?
Beste Grüße
Thomas
Sub Dennis()
Dim c As Range, Bereich As Range, ErgBereich As Range
Dim Ant As Byte
On Error Resume Next
Set Bereich = Application.InputBox("Bitte Bereich mit der Maus markieren", _
"Bereichswahl", , , , , , 8)
If Bereich Is Nothing Then
MsgBox "Nichts selektiert !" & vbCr & vbCr & "Makro-Abbruch !", _
vbOKOnly + vbCritical, "Dezenter Hinweis für " & Application.UserName & ":"
Exit Sub
End If
On Error GoTo 0
Application.ScreenUpdating = False
Ant = MsgBox("Nur farbige Zellen markieren ?", vbYesNo + vbQuestion, _
"Frage an " & Application.UserName & ":")
For Each c In Bereich
If Ant = 6 Then
If c.Interior.ColorIndex xlNone Then
Set ErgBereich = c
Exit For
End If
Else
If c.Interior.ColorIndex = xlNone Then
Set ErgBereich = c
Exit For
End If
End If
Next c
If ErgBereich Is Nothing Then
MsgBox "Nichts gefunden !", vbOKOnly + vbInformation, _
"Dezenter Hinweis für " & Application.UserName & ":"
Else
For Each c In Bereich
If Ant = 6 Then
If c.Interior.ColorIndex xlNone Then
Set ErgBereich = Application.Union(ErgBereich, c)
End If
Else
If c.Interior.ColorIndex = xlNone Then
Set ErgBereich = Application.Union(ErgBereich, c)
End If
End If
Next c
ErgBereich.Select
Set ErgBereich = Nothing
Set Bereich = Nothing
End If
Application.ScreenUpdating = True
End Sub