1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
Sub STDTransfer()
' # Erklärung den verschiedenen Variablen
Dim STD As Worksheet
Dim SAP As Worksheet, Datenbasis As Worksheet
Dim C As Range
Dim ligne As Long
Dim rRange As Range
Dim D As Range, E As Range
' # Schaffung einer Verknüpfung für die Namen den Blättern
Set STD = Worksheets("Stunden ink. Kaufl")
Set SAP = Worksheets("SAP")
Set Datenbasis = Worksheets("Datenbasis")
ligne = 2
' # Überträgt die Datei aus dem SAP Blatt nach dem Stunden inkl Kaufl blatt
Set rRange = Range(SAP.Cells(2, 8), SAP.Cells(SAP.Rows.Count, 8).End(xlUp))
For Each C In rRange
If C.Value <> 0 Then
C.Offset(0, -7).Copy Destination:=STD.Cells(ligne, 1)
C.Offset(0, -6).Copy Destination:=STD.Cells(ligne, 2)
C.Offset(0, -5).Copy Destination:=STD.Cells(ligne, 3)
C.Offset(0, -3).Copy Destination:=STD.Cells(ligne, 7)
C.Offset(0, -2).Copy Destination:=STD.Cells(ligne, 8)
C.Offset(0, -1).Copy Destination:=STD.Cells(ligne, 9)
C.Offset(0, 2).Copy Destination:=STD.Cells(ligne, 12)
C.Offset(0, 3).Copy Destination:=STD.Cells(ligne, 14)
C.Offset(0, 4).Copy Destination:=STD.Cells(ligne, 15)
C.Offset(0, 5).Copy Destination:=STD.Cells(ligne, 16)
C.Offset(0, 7).Copy Destination:=STD.Cells(ligne, 18)
C.Offset(0, 10).Copy Destination:=STD.Cells(ligne, 21)
C.Offset(0, 0).Copy Destination:=STD.Cells(ligne, 10)
ligne = ligne + 1
End If
Next
' # Schreibt die Jahre in der Jahre Spalte und der period in der Periode Spalte für jede WBS-Element
For Each D In STD.Range("A2:A" & STD.Cells(Rows.Count, 1).End(xlUp).Row)
D.Offset(0, 3).Value = Format(Month(D.Value))
D.Offset(0, 4).Value = Format(Year(D.Value))
Next
' # Kolorirt die Linien der Kaufleute in gelb. Die Kaufleute sind mit ein x in der Datenbasis notiert
For Each E In STD.Range("G2:G" & STD.Cells(Rows.Count, 1).End(xlUp).Row)
With Datenbasis.Range(Datenbasis.Cells(2, 1), Datenbasis.Cells(Datenbasis.Cells(Rows.Count, 1).End(xlUp).Row, 1))
Set D = .Find(E, LookIn:=xlValues, lookat:=xlWhole)
If Not D Is Nothing Then
If Trim(D.Offset(0, 4)) = "x" Then
E.EntireRow.Interior.Color = 10092543
End If
End If
End With
Next
End Sub |