ich habe ein kleines Problem mit einem VBA code und hoffe hier kann mir jemand helfen.
Situation ist folgende:
a) ich habe eine Excel Tabelle mit Aufgaben; das Zieldatum steht in Spalte G.
b) Bei einer Verzögerung soll das Datum in G nach H verschoben werden (um einen Überblick über die Historie zu wahren).
c) Sollte Sich das Datum in G nochmals ändern, so soll das Datum in H hinzugefügt werden.
Zusatz:
+ Spalte G soll als Datumsformat TT/MM/JJ in schwarzz anzeigen
+ Spalte H soll jedes Datum in TT/MM/JJ in rot durchgestrichen anzeigen
Ich habe hierfür folgenden Code:
Sub Action_Delayed()
' Macro Delayed Action
Cells(ActiveCell.Row, 7).Activate
S = Chr$(10) 'separator skip line
Sheets("Actions").Select 'confirms worksheet
Actual = ActiveCell.FormulaR1C1
Col = ActiveCell.Column
If Col = 7 And ActiveCell.Value "" Then
Actual = Format(Actual, "dd/mm/yy") 'select actual date and add _
separator
Delay = Format(Actual, "dd/mm/yy") 'format delay date
Delay = ActiveCell.Offset(0, 1).FormulaR1C1 'copy delayed field
If Delay = "" Then
ActiveCell.Offset(0, 1).FormulaR1C1 = Actual 'update delayed field
With Selection.Font 'add red color
.Color = -16776961
.TintAndShade = 0
End With
Else
ActiveCell.Offset(0, 1).FormulaR1C1 = Delay + S + Actual
End If
ActiveCell.Value = ""
End If
End Sub
Problem ist folgendes:
1. in der Situation C wird zwar das Datum in H eingefügt, jedoch ist geht das Datumsformat verloren und das Datum wird numerisch angezeigt
2. Meine Spalte G wird mit roter Schrift formatiert
3. Spalte H with im Dtaumsformat MM/TT/JJ angezeigt
4. der Code funktioniert manchmal, manchmal aber auch nicht. Soll heissen, es ist unabhängig vom User, PC, Spracheinstellungen, etc...
Kann mir hier bitte jemand den rechten Weg weisen.
Dnake & Gruß,
Boris