Makro übertragen und abändern
05.09.2005 14:42:28
Dietmar
Ich habe gestern von Herbert H. einen Code für meinen Jahresschichtkalender erhalten der perfekt funktioniert.
'Public
Sub Schicht_eintr()
Dim sArr, i%, s As Byte, x$, a As Byte, wt As Byte
Dim w As Byte, z As Byte
sArr = Array("I", "II", "Sp", "III", "D")
On Error GoTo ende
With Selection
x = .Value
i = 5
s = .Column
End With
Select Case x
Case sArr(0): a = 0
Case sArr(1): a = 1
Case sArr(2): a = 2
Case sArr(3): a = 3
Case sArr(4): a = 4
End Select
With ActiveSheet
wt = Weekday(.Cells(i, s - 4))
If Selection.Value = "II" And wt = 2 Then Exit Sub
If a = 1 And wt = 1 Then
Cells(i, s) = sArr(4)
i = i + 1
a = a + 1
End If
If wt = 2 Then a = a + 1
If a = 5 Then a = 0
If a = 1 Then z = 7 Else: z = 1
If wt = 1 Then z = 1
Do
.Cells(i, s) = sArr(a)
wt = Weekday(.Cells(i, s - 4))
i = i + 1
Loop Until wt = z
If a = 1 Then
.Cells(i, s) = sArr(4)
i = i + 1
End If
a = a + 1
If a = 5 Then a = 0
If a = 1 Then w = i - 1 Else: w = i
Do Until i = w + 7
.Cells(i, s) = sArr(a)
i = i + 1
Loop
If a = 1 Then
.Cells(i, s) = sArr(4)
i = i + 1
End If
a = a + 1
If a = 5 Then a = 0
If a = 1 Then w = i - 1 Else: w = i
Do Until i = w + 7
.Cells(i, s) = sArr(a)
i = i + 1
Loop
If a = 1 Then
Cells(i, s) = sArr(4)
i = i + 1
End If
a = a + 1
If a = 5 Then a = 0
If a = 1 Then w = i - 1 Else: w = i
Do Until i = w + 7
.Cells(i, s) = sArr(a)
i = i + 1
Loop
If a = 1 Then
Cells(i, s) = sArr(4)
i = i + 1
End If
a = a + 1
If a = 5 Then a = 0
If a = 1 Then w = i - 1 Else: w = i
Do Until i = w + 7
.Cells(i, s) = sArr(a)
i = i + 1
If i > 34 Then GoTo weiter
Loop
If a = 1 Then
.Cells(i, s) = sArr(4)
i = i + 1
End If
a = a + 1
If a = 5 Then a = 0
If a = 1 Then w = i - 1 Else: w = i
Do Until i > 35
.Cells(i, s) = sArr(a)
i = i + 1
Loop
weiter:
For i = 32 To 34
If Cells(i, s - 3) = "" Then
Cells(i, s) = ""
End If
Next
End With'
ende:
End Sub
Er ist in dieser Tabelle... https://www.herber.de/bbs/user/26286.xls ... und bewirkt das wenn ich in Zelle E4 die Schicht in z.B. I stelle, der ganze Monat automatisch anpasst.
Jetzt möchte ich diesen Code auch in meinen Stundenzettel einbauen. Nur komme ich mit dem o.g. Code nicht so ganz klar und habe keine Ahnung wie bzw an welchen Stellen ich diesen anpassen muss.
Hier mal der Stundenzettel...
Die Datei https://www.herber.de/bbs/user/26302.xls wurde aus Datenschutzgründen gelöscht
Im Jahreskalender geht er vertikal in Zelle E4 für den Monat.
Kann mir da jemand von Euch beim "Umbau" helfen?!
Gruß
Dietmar