Hallo zusammen!
Der nachfolgende Code läuft einwandfrei, zur kurzen Erklärung: Wird in Spalte B,C oder D ein Zeichen gesetzt, wird automatisch
das aktuelle Datum vermerkt. Wird in Spalte B ein Zeichen gesetzt färbt sich zusätzlich die komplette Zeile grau, in Spalte C färbt sich
die Zeile rot und in Spalte D grün.
Das einzige Problem ist der
"Select"
-Befehl. Klicke ich z.B. auf
"B12"
, setze irgendein Zeichen -> und möchte dann anschließend
mit der Maus sofort zu
"D20"
wechseln muss man immer 2mal in die Zelle klicken, weil zuvor nochmal B markiert wurde.
Der Befehl, der dafür verantwortlich ist, ist wahrscheinlich
"<strong>Target.EntireRow.Columns("
B
").Select</strong>"
, weiß aber nicht was
ich sonst schreiben soll?! Kann mir jemand weiterhelfen?
Danke schon mal!!
Private
Sub
Worksheet_Change(
ByVal
Target
As
Range)
Dim
strZelle
As
String
If
Target.Row > 500
Then
Exit
Sub
If
Target.Row < 8
Then
Exit
Sub
If
Target.Column > 4
Then
Exit
Sub
If
Target.Column = 2
Then
If
Target.Column = 2
Then
strZelle =
"$B$"
&
CStr
(Target.Row)
Target.EntireRow.Columns(
"B:H"
).
Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:=
"="
& strZelle &
"<> "
""
""
With
Selection.FormatConditions(1).Font
.Bold =
True
.Italic =
False
.ColorIndex = 15
End
With
<strong>Target.EntireRow.Columns(
"B"
).
Select
</strong>
End
If
If
Target =
""
Then
Exit
Sub
Application.EnableEvents =
False
If
Not
IsDate(Target)
Then
Target =
Date
Target.Offset(0, 1) =
""
Target.Offset(0, 2) =
""
ElseIf
Target.Column = 3
Then
If
Target.Column = 3
Then
strZelle =
"$C$"
&
CStr
(Target.Row)
Target.EntireRow.Columns(
"C:H"
).
Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:=
"="
& strZelle &
"<> "
""
""
With
Selection.FormatConditions(1).Font
.Bold =
True
.Italic =
False
.ColorIndex = 3
End
With
<strong>Target.EntireRow.Columns(
"C"
).
Select
</strong>
End
If
If
Target =
""
Then
Exit
Sub
Application.EnableEvents =
False
If
Not
IsDate(Target)
Then
Target =
Date
Target.Offset(0, 1) =
""
Target.Offset(0, -1) =
""
ElseIf
Target.Column = 4
Then
If
Target.Column = 4
Then
strZelle =
"$D$"
&
CStr
(Target.Row)
Target.EntireRow.Columns(
"D:H"
).
Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:=
"="
& strZelle &
"<> "
""
""
With
Selection.FormatConditions(1).Font
.Bold =
True
.Italic =
False
.ColorIndex = 50
End
With
<strong> Target.EntireRow.Columns(
"D"
).
Select
</strong>
End
If
If
Target =
""
Then
Exit
Sub
Application.EnableEvents =
False
If
Not
IsDate(Target)
Then
Target =
Date
Target.Offset(0, -1) =
""
Target.Offset(0, -2) =
""
End
If
Application.EnableEvents =
True
End
Sub