folgenden Code habe recherchiert. Wie kann ich diesen Code nun für die ganze Arbeitsmappe verfügbar machen ohne es in jedes Sheet zu kopieren.
Vielen Dank vorab für eure Hilfe.
Gruß, Pet
Private Sub Worksheet_Change(ByVal Target As Range)
'* H. Ziplies *
'* 04.08.09 *
'* erstellt von HajoZiplies@web.de *
'* http://Hajo-Excel.de/
' Füllfarbe
' für Schrift RaZelle.Font.ColorIndex
Dim RaBereich As Range, RaZelle As Range
' Bereich der Wirksamkeit
Set RaBereich = Range("B4:AF26")
' noch mehr Bereiche
'Set RaBereich = Union(Range("C11:AG11 , C13:AG13, C15:AG15 , C17:AG17 , C19:AG19 , C21: _
AG21 , C27:AE27 , C29:AE29, C31:AE31, C33:AE33"), _
' Range("C35:AE35, C37:AE37, C43:AG43, C45:AG45 , C47:AG47 , C49:AG49 ,C51:AG51 , C53: _
AG53 , C59:AF59 , C61:AF61 , C63:AF63 , C65:AF65"), _
' Range("C67:AF67 , C69:AF69 , C75:AG75 , C77:AG77 , C79:AG79 , C81:AG81 , C83:AG83 , _
C85:AG85 ,C91:AF91 , C93:AF93 , C95:AF95 , C97:AF97"), _
' Range("C99:AF99 , C101:AF101, C107:AG107 , C109:AG109 , C111:AG111 , C113:AG113 , C115: _
_
_
_
_
AG115 , C117:AG117 , C123:AG123 , C125:AG125"), _
' Range("C127:AG127 , C129:AG129 , C131:AG131 , C133:AG133 , C139:AF139 , C141:AF141 , _
_
_
_
_
C143:AF143 , C145:AF145 , C147:AF147 , C149:AF149"), _
' Range("C155:AG155, C157:AG157 , C159:AG159 , C161:AG161 , C163:AG163 , C165:AG165 , _
C171:AF171 , C173:AF173 , C175:AF175 , C177:AF177 "), _
' Range("C179:AF179 , C181:AF181, C187:AG187 , C189:AG189 , C191:AG191 , C193:AG193 , _
C195:AG195 , C197:AG197"))
' ab Vesion XP braucht der Schutz nicht aufgehoben werden
' Formatierung bei Schutz kann über Dialog Schutz eingestellt werden
' Zelle die in dem Bereich liegen auf die Varible schreiben
' damit werden nur noch die Zellen bearbeitet die im vorgegeben Bereich liegen
' jede Zelladresse ist einzeln angegeben
Set RaBereich = Intersect(RaBereich, Range(Target.Address))
If Not RaBereich Is Nothing Then
'ActiveSheet.Unprotect ("Passwort")
For Each RaZelle In RaBereich
With RaZelle
Select Case UCase(.Value) ' UMWANDLUNG DER Eingabe in Großbuchstaben
Case "U"
.Interior.ColorIndex = 5
' schwarz
.Font.ColorIndex = 0
' Schriftfarbe schwarz
'.NumberFormat = "General"
' Zellenformat Standard
Case "K"
.Interior.ColorIndex = 46
' gelb
.Font.ColorIndex = 0
' Schriftfarbe schwarz
'.NumberFormat = "General"
' Zellenformat Standard
Case "Z"
.Interior.ColorIndex = 3
' rot
.Font.ColorIndex = 0
' Schriftfarbe schwarz
'.NumberFormat = ";;;"
' nicht sichtbar
Case "R"
.Interior.ColorIndex = 28
' grün
.Font.ColorIndex = 0
' Schriftfarbe automatisch
'.NumberFormat = "General"
' Zellenformat Standard
'Case "KLAUS"
'.Interior.ColorIndex = 5
' blau
'.Font.ColorIndex = 0
' Schriftfarbe schwarz
'.NumberFormat = "General"
' Zellenformat Standard
'Case Else
'.Interior.ColorIndex = xlNone
' Keine
'.Font.ColorIndex = 0
' Schriftfarbe automatisch
'.NumberFormat = "General"
' Zellenformat Standard
End Select
End With
Next RaZelle
'ActiveSheet.protect ("Passwort")
End If
Set RaBereich = Nothing
End Sub