AW: Spalten und Zeilen berechnen mit bedingungen
11.12.2015 12:52:00
Andi
Hallo,
habe das soweit für jeden Monat mit Multiplikator hinbekommen.
Wie bekomme ich das hin das die Zeilen mit den Bedingungen der Kurzz. berechnent werden
Kurzz. Berechnung
R______R-R1-R2
B______B-B1
C______C-C1
D______D-D1
E______E-E1-E2
H______H-H1
M1_____M1+M2
M5_____M5a +M7a+M8+M7+M5
M1_____M1-M4
P1____(P1-P2)+(P3-P4)
z.B.
Wenn in Splate H das Kurzzeichen R,R1,R2 steht sollen die Zeilen von R-R1-R2 in der Tabelle Stromverbrauch für die einzelnen Monate berechnent werden.
Gruß Andi
Bedanke mich schon mal in vorraus!
Hier nochmal eine aktuelle Datei:
https://www.herber.de/bbs/user/102183.xlsm
Der aktuelle Code:
Sub Stromverbrauch()
Dim i As Integer
Set w1 = Tabelle1
Set w2 = Tabelle4
letzteZeile = w1.Cells(Rows.Count, 9).End(xlUp).Row
w2.Activate
For i = 6 To letzteZeile
'Januar
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 6).Value = (w1.Cells(i, 10).Value - w1.Cells(i, 9).Value) * w1.Cells(i, 7). _
Value
Else
w2.Cells(i, 6).Value = (w1.Cells(i, 10).Value - w1.Cells(i, 9).Value)
End If
If w1.Cells(i, 9).Value = "" Then
w2.Cells(i, 6).Value = ""
End If
'Februar
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 7).Value = (w1.Cells(i, 11).Value - w1.Cells(i, 10).Value) * w1.Cells(i, 7). _
Value
Else
w2.Cells(i, 7).Value = (w1.Cells(i, 11).Value - w1.Cells(i, 10).Value)
End If
If w1.Cells(i, 10).Value = "" Then
w2.Cells(i, 7).Value = ""
End If
'März
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 8).Value = (w1.Cells(i, 12).Value - w1.Cells(i, 11).Value) * w1.Cells(i, 7). _
Value
Else
w2.Cells(i, 8).Value = (w1.Cells(i, 12).Value - w1.Cells(i, 11).Value)
End If
If w1.Cells(i, 11).Value = "" Then
w2.Cells(i, 8).Value = ""
End If
'April
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 9).Value = (w1.Cells(i, 13).Value - w1.Cells(i, 12).Value) * w1.Cells(i, 7). _
Value
Else
w2.Cells(i, 9).Value = (w1.Cells(i, 13).Value - w1.Cells(i, 12).Value)
End If
If w1.Cells(i, 12).Value = "" Then
w2.Cells(i, 9).Value = ""
End If
'Mai
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 10).Value = (w1.Cells(i, 14).Value - w1.Cells(i, 13).Value) * w1.Cells(i, 7) _
.Value
Else
w2.Cells(i, 10).Value = (w1.Cells(i, 14).Value - w1.Cells(i, 13).Value)
End If
If w1.Cells(i, 13).Value = "" Then
w2.Cells(i, 10).Value = ""
End If
'Juni
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 11).Value = (w1.Cells(i, 15).Value - w1.Cells(i, 14).Value) * w1.Cells(i, 7) _
.Value
Else
w2.Cells(i, 11).Value = (w1.Cells(i, 15).Value - w1.Cells(i, 14).Value)
End If
If w1.Cells(i, 14).Value = "" Then
w2.Cells(i, 11).Value = ""
End If
'Juli
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 12).Value = (w1.Cells(i, 16).Value - w1.Cells(i, 15).Value) * w1.Cells(i, 7) _
.Value
Else
w2.Cells(i, 12).Value = (w1.Cells(i, 16).Value - w1.Cells(i, 15).Value)
End If
If w1.Cells(i, 15).Value = "" Then
w2.Cells(i, 12).Value = ""
End If
'August
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 13).Value = (w1.Cells(i, 17).Value - w1.Cells(i, 16).Value) * (w1.Cells(i, _
7).Value)
Else
w2.Cells(i, 13).Value = (w1.Cells(i, 17).Value - w1.Cells(i, 16).Value)
End If
If w1.Cells(i, 16).Value = "" Then
w2.Cells(i, 13).Value = ""
End If
'September
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 14).Value = (w1.Cells(i, 18).Value - w1.Cells(i, 17).Value) * (w1.Cells(i, _
7).Value)
Else
w2.Cells(i, 14).Value = (w1.Cells(i, 18).Value - w1.Cells(i, 17).Value)
End If
If w1.Cells(i, 17).Value = "" Then
w2.Cells(i, 14).Value = ""
End If
'Oktober
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 15).Value = (w1.Cells(i, 19).Value - w1.Cells(i, 18).Value) * (w1.Cells(i, _
7).Value)
Else
w2.Cells(i, 15).Value = (w1.Cells(i, 19).Value - w1.Cells(i, 18).Value)
End If
If w1.Cells(i, 18).Value = "" Then
w2.Cells(i, 15).Value = ""
End If
'November
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 16).Value = (w1.Cells(i, 20).Value - w1.Cells(i, 19).Value) * (w1.Cells(i, _
7).Value)
Else
w2.Cells(i, 16).Value = (w1.Cells(i, 20).Value - w1.Cells(i, 19).Value)
End If
If w1.Cells(i, 19).Value = "" Then
w2.Cells(i, 16).Value = ""
End If
'Dezember
If w1.Cells(i, 7).Value "" Then
w2.Cells(i, 17).Value = (w1.Cells(i, 21).Value - w1.Cells(i, 20).Value) * (w1.Cells(i, _
7).Value)
Else
w2.Cells(i, 17).Value = (w1.Cells(i, 21).Value - w1.Cells(i, 20).Value)
End If
If w1.Cells(i, 21).Value = "" Then
w2.Cells(i, 17).Value = ""
End If
Next i
End Sub